If you’re selecting a datetime from your database and the time is incorrect because it’s a UTC timestamp instead of being in your local timezone, try the following:

DATEADD(hour, -DATEDIFF(hour, CURRENT_TIMESTAMP, GETUTCDATE()), [Table].[UTC_Datetime_Field]) AS [Local_Datetime]


This gets the difference in hours between the current UTC time and the current time on your SQL server, then subtracts that difference from the datetime field in your database.

Be aware that you might need to add instead of subtract, depending on where you are in the world. In that case, change the minus sign (-) to a plus (+) sign immediately before DATEDIFF.

Share This Via: