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:

Post a Comment

Remember, if you want me to respond to your comment, then you need to use a Google/OpenID account to leave the comment.