T-SQL: Convert from UTC Date to Local Date

Here’s a quick T-SQL expression to convert from a UTC Date to Local Date:

DATEADD(HH, DATEDIFF(HH, GETUTCDATE(), GETDATE()), MyUtcDate) AS MyLocalDate

An even better idea would be to avoid the conversion by using the datetimeoffset sql column type.

This entry was posted in T-SQL. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *