Daylight savings time in Sql Server -
We are using an old application which stores dates in C / UNIX format. The time is basically the number of seconds since January 1, 1970. The date is stored in an SQL Server database as an integer. I am writing a scene for a report using these dates.
So far, I am converting from Unix time to a native date time:
Add date, 3600 + Unix_time, '1/1/1970' ) 3600 UTC to convert to our local GMT +1 time zone. This is true in winter, but due to daylight saving time in summer, one hour is closed.
Is there an inherent way to convert from UTC to local time in SQL Server?
Instead of 3600, you want to do DateDiff (s, getutcdate), getdate ()) + unix_time, which will give you the correct offset from UTC time.Cheers, Eric
Comments
Post a Comment