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.9K Product Ideas
- 1.9K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 303 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 104 SQL DataFlows
- 640 Datasets
- 2.2K Magic ETL
- 4K Visualize
- 2.5K Charting
- 767 Beast Mode
- 70 App Studio
- 43 Variables
- 715 Automate
- 185 Apps
- 460 APIs & Domo Developer
- 56 Workflows
- 14 DomoAI
- 39 Predict
- 16 Jupyter Workspaces
- 23 R & Python Tiles
- 402 Distribute
- 116 Domo Everywhere
- 277 Scheduled Reports
- 9 Software Integrations
- 134 Manage
- 131 Governance & Security
- 8 Domo Community Gallery
- 44 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 111 Community Announcements
- 4.8K Archive