Wednesday, July 11, 2012

Sql Server–Convert UTC time to Local Time

Here is a quick function that you can plug into your sql query to convert a field that has UTC time to local time:

dateadd(hour, DATEDIFF (HH, GETUTCDATE(), GETDATE()), Timestamp) as ltime

Where Timestamp should be replaced by the field in your table that contains date-time in UTC.

No comments: