Forum Discussion

Hopeisgood1's avatar
Hopeisgood1
Copper Contributor
Mar 27, 2025
Solved

Change the timezone for date/time - Arizona

Hello,   I am in Arizona with no daylight saving. The SQL database I am pulling date/time codes has nightmarish Epoch (INT) fields for the date/time fields and it's in Eastern Time Zone. I figured ...
  • rodgerkong's avatar
    rodgerkong
    Apr 02, 2025

    If the number 1704228 in db shows time '1/2/2024 1:55:05 PM' in the UI and the time is Arizona Time, then the number stored in db must be an UTC timestamp. Code below will make the conversion

    SELECT FORMAT(DATEADD(MILLISECOND, PARSE(RIGHT(Completed_Date, 3) AS INT), DATEADD(SECOND, PARSE(LEFT(Completed_Date, 10) AS INT), CAST('1970-01-01' AS DATETIME2)))
        AT TIME ZONE 'UTC' AT TIME ZONE 'US Mountain Standard Time',  'MM/dd/yy hh:mm:ss tt', 'en-us' )

Resources