Microsoft
Software
Hardware
Network
Question : Convert SQL datetime from UTC to local
I have a MS SQL database in which all datetimes are stored as UTC(GMT). All work that this database keeps track of is in the EST time zone. I need to make a stored procedure that can convert a given datetime to whatever the local time should be. I've figured out how to do this with an offset and the DATEADD() function, but I dont know how to determine the appropriate offset for the datetime. I could use this:
DATEADD(hour,DATEDIFF(hour
,GETUTCDAT
E(),GETDAT
E()),@varD
ate)
but this calculates the offset based on the current time, which fails in the case where I am calculating a datetime from daylight savings at a time that isnt in daylight savings.
It seems like if I could seed GETDATE and GETUTCDATE with the date I am working with that would work, but I dont know how or if I can do that.
Thanks!
Answer : Convert SQL datetime from UTC to local
Link to a solution that has a downloadable database of timezones, in standard TIME_ZONE_INFORMATION structure.
http://www.codeproject.com
/KB/databa
se/
Convert
UTCToLocal
.aspx
Random Solutions
Sort by last word in field
Windows XP Help and Support won't launch
how do I change find and change the hosts file on windows 2008
Exchange 2007 and Samsung SCH-i760 synching
How to insert data with more than 4000 char in clob datatype in oracle 9 i
SQL Server 2005 CLR Trigger - Audit Table Requires Additional Information
NZ fuction does not work properly
Calendar journaling messages stuck in Submission queue with Event ID 9213 logged in app log every 30 mins
"Sysinternals Process Explorer has encountered an error and must close."
Shared mailbox for several users, via an existing mail account, and still wanting mail forwarding options