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
- 2K Product Ideas
- 2K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 311 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3.8K Transform
- 655 Datasets
- 115 SQL DataFlows
- 2.2K Magic ETL
- 811 Beast Mode
- 3.3K Visualize
- 2.5K Charting
- 80 App Studio
- 45 Variables
- 771 Automate
- 190 Apps
- 481 APIs & Domo Developer
- 77 Workflows
- 23 Code Engine
- 36 AI and Machine Learning
- 19 AI Chat
- AI Playground
- AI Projects and Models
- 17 Jupyter Workspaces
- 410 Distribute
- 120 Domo Everywhere
- 280 Scheduled Reports
- 10 Software Integrations
- 142 Manage
- 138 Governance & Security
- 8 Domo Community Gallery
- 48 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 113 Community Announcements
- 4.8K Archive