I need to capture the time zone of the DB server and adjust some date columns in some of my tables to make sure all the dates are using PST.
My database is distributed into different smaller databases (example into laptops, PDAs etc..) around the world.
End of day I will sync all the databases in PST time zone. Is there a command in SQL to capture the timezone.
Thanks
The query below will give the offset:
select datediff(hour, GETUTCDATE(), CURRENT_TIMESTAMP)
You can map this to a table that contains the various timezones (pre-defined) and use it in your queries.
|||Is there any way to know if the timezone supports daylight saving time? This gets the current offset, but not the timezone meta data.
|||Thanks for the quick response. This will help me to start working on my code.
Thanks for your time.
|||Not without reading the registry or writing extended SP or calling some OS utility or SQLCLR code. But it is very easy to build a TimeZone dimension/table that contains all the predefined offsets and attributes. You can then use the obtained offset to query the TimeZone table to get the rest of the details.|||That's what I thought. Thanks!
No comments:
Post a Comment