'1 hour difference in timestamp/ timestampadd in vertica - Vertica
Why there is a difference of 1 hour in timestamp in vertica . Is it because of Daylight savings? How to avoid that?
Timezone
dbadmin=> show timezone;
name | setting
----------+-----------------
timezone | America/Toronto
April month shows correct
dbadmin=> select '2022-04-10 09:30:00+0530'::TIMESTAMPTZ;
?column?
------------------------
2022-04-10 00:00:00-04
March month shows 1 hour lag##
dbadmin=> select '2022-03-10 09:30:00+0530'::TIMESTAMPTZ;
?column?
------------------------
2022-03-09 23:00:00-05
I want to go back 30 days from April to March but instead of 2022-03-11 00:00:00-04, I am getting one hour difference '2022-03-10 23:00:00-05', while the same things work well in April-May
April to March
dbadmin=> select TIMESTAMPADD('DAY', -1*30, '2022-04-10 00:00:00-04');
timestampadd
------------------------
2022-03-10 23:00:00-05
May to April
dbadmin=> select TIMESTAMPADD('DAY', -1*30, '2022-05-10 00:00:00-04');
timestampadd
------------------------
2022-04-10 00:00:00-04
Solution 1:[1]
Thanks for your answer in the comments.
UTC - Greenwich mean time has no daylight saving time. Your local 'America/Toronto' time, however, has it. So you are 4 hours away from UTC in summer, and 5 hours away from UTC in winter.
Works as designed - or "it's not a bug, it's a feature" ....
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | marcothesane |