Created
October 26, 2022 18:22
-
-
Save ctkdev/6a0764c778641bbecd5dc1c83a7525ef to your computer and use it in GitHub Desktop.
Time Shift a DateTime in a MySQL Column from US Eastern TZ to UTC for dates in years 2021-2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://www.timeanddate.com/time/change/usa | |
| select dateTimeAccess dateTimeAccessEastern, | |
| CASE | |
| when dateTimeAccess between '2021-03-14 02:00:00' and '2021-11-07 02:00:00' then DATE_FORMAT( | |
| DATE_ADD(dateTimeAccess, INTERVAL 4 HOUR), '%Y-%m-%d %H:%i:%s') | |
| when dateTimeAccess between '2021-11-07 02:00:01' and '2022-03-13 02:00:00' then DATE_FORMAT( | |
| DATE_ADD(dateTimeAccess, INTERVAL 5 HOUR), '%Y-%m-%d %H:%i:%s') | |
| when dateTimeAccess > '2022-03-13 02:00:01' then DATE_FORMAT( | |
| DATE_ADD(dateTimeAccess, INTERVAL 4 HOUR), '%Y-%m-%d %H:%i:%s') | |
| end as dateTimeAccessUTC | |
| from all_logs | |
| order by dateTimeAccess; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment