Is there any easier way to adjust date error caused by timezone?
for example, my google sheet raw data is 3/31/2024 23:16
when I upload it into DOMO, it appears as 4/1/2024 7:16 PM
I had to use Convert_TZ to adjust it.
this time I find there is the problem of summer time and winter time, which makes it more difficult to adjust time zone.
anybody who knows more easier way to adjust my DOMO uploaded date?
thank you for your help!
Best Answer
-
You can use Beast Mode to adjust your timestamp for time zone differences.
Step 1: Identify the time zone offset
Determine the fixed offset between the time zones. For example, if you want to adjust from UTC to a specific time zone, you need to know the standard offset (e.g., UTC-5 for EST).Step 2: Adjust for Daylight Saving Time
Create a logic to account for DST. This can be done using conditional statements in Beast Mode.
CASE
WHEN DATE_FORMAT(your_date_column, '%m-%d') BETWEEN '03-08' AND '11-01' THEN DATE_SUB(your_date_column, INTERVAL 4 HOUR)
ELSE DATE_SUB(your_date_column, INTERVAL 5 HOUR)
ENDOr you can manipulate it in an ETL or Python.
from datetime import datetime
import pytz #Your date string from Google Sheets date_str = '2024-03-31 23:16'
date_format = '%Y-%m-%d %H:%M' #Parse the date date_obj = datetime.strptime(date_str, date_format) #Define the original and target timezones original_tz = pytz.timezone('UTC')
target_tz = pytz.timezone('America/New_York') #Localize the date to the original timezone and convert to the target timezone localized_date = original_tz.localize(date_obj)
adjusted_date = localized_date.astimezone(target_tz) print(adjusted_date)** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **1
Answers
-
You can use Beast Mode to adjust your timestamp for time zone differences.
Step 1: Identify the time zone offset
Determine the fixed offset between the time zones. For example, if you want to adjust from UTC to a specific time zone, you need to know the standard offset (e.g., UTC-5 for EST).Step 2: Adjust for Daylight Saving Time
Create a logic to account for DST. This can be done using conditional statements in Beast Mode.
CASE
WHEN DATE_FORMAT(your_date_column, '%m-%d') BETWEEN '03-08' AND '11-01' THEN DATE_SUB(your_date_column, INTERVAL 4 HOUR)
ELSE DATE_SUB(your_date_column, INTERVAL 5 HOUR)
ENDOr you can manipulate it in an ETL or Python.
from datetime import datetime
import pytz #Your date string from Google Sheets date_str = '2024-03-31 23:16'
date_format = '%Y-%m-%d %H:%M' #Parse the date date_obj = datetime.strptime(date_str, date_format) #Define the original and target timezones original_tz = pytz.timezone('UTC')
target_tz = pytz.timezone('America/New_York') #Localize the date to the original timezone and convert to the target timezone localized_date = original_tz.localize(date_obj)
adjusted_date = localized_date.astimezone(target_tz) print(adjusted_date)** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **1
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 738 Beast Mode
- 56 App Studio
- 40 Variables
- 685 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 124 Manage
- 121 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive