Forum Discussion
ElliotP
Post Prodigy
9 years agoUTC to AEST
Morning, The DateTime column in my sql table is in UTC time, but I would like this column to be in the AEST (-10 or -11) timezone. I've read quite a lot through the forums and all of the solution...
- 9 years ago
You can use the table and function from my post as illustrated in this video:
steven_steven
8 years agoRegular Visitor
Perhaps this can help others.
I've taken a different way to solve for DST with the plan to not rely on a table (not that there's anything wrong with that either!)
Use case may be limited as it addresses converting UTC to another timezone with daylight savings time support with DST starting on the 2nd Sunday in March and ending on the 1st Sunday in November.
Last Refresh Pacific = // First let's find the date of the second Sunday of March // For the forumla below: // In DAX, we use the functions DATE() and WEEKDAY() // "1+7*2", generically, "1+7*n" where n represents // the nth occurence of that "weekday name" // "8-1", generically, "8-y", where // y can be a number from 1 to 7, where // 1 = Sunday through to 7 = Saturday // // Thus, the date of the second Sunday of the month // is returned to the variable ZZQQ_DST_START //
// ZZQQ_DATE is the date/time in UTC.
VAR ZZQQ_DST_START = DATE(YEAR(ZZQQ_DATE),3,1+7*2) - WEEKDAY(DATE(YEAR(ZZQQ_DATE),3,8-1)) // Next let's find the date of the first Sunday in November VAR ZZQQ_DST_END = DATE(YEAR(ZZQQ_DATE),11,1+7*1) - WEEKDAY(DATE(YEAR(ZZQQ_DATE),11,8-1)) RETURN IF ( // Evaluate if ZZQQ_DATE is between DST start and end // If yes, change time to Pacific Daylight Savings Time // else, change time to Pacific Standard Time (ZZQQ_DATE >= ZZQQ_DST_START) && (ZZQQ_DATE <= ZZQQ_DST_END), ZZQQ_DATE + (-7/24), // If condition matches, convert UTC to PDT ZZQQ_DATE + (-8/24) // Else convert UTC to PST )