I am working on an application in which:
- Authentication token has an expiration of 2 hours from its creation time.
- Token creation and expiration time stored in DB are local date / time (i.e. EST)
- Tokens generated within 2 hours before DST starts, expire in 1 hour time as clock moves 1 hour forward.
- For ex: If a token is created at 1:30 AM on 14th March 2021, then its creation and expiration time will set in DB as “2021-03-14 01:30:00” and “2021-03-14 03:30:00” respectively. Now, suppose DST starts at 2 PM, server time will be 3:00 at that moment and the token which should be valid till 3:30 will now expire at 2:30
currently I am using the query which start failing when day light saving starts in US. The below query is used to fetch active token from DB:
SELECT * FROM tbl1 WHERE TOKEN_VALUE = 'xyztoken' AND
TOKEN_EXPIRATION > CURRENT_TIMESTAMP;
Is there any way to tweak the above query so that it returns the right result once day light saving start in US.
TOKEN_EXPIRATION and TOKEN_CREATION fields are in TIMESTAMP
INSERT) statement for how you are storing the token expiration in the table. - MT0