Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How do I convert UTC to specified time zone in T-SQL (SQL Server 2008 R2)?

$
0
0

Question: How do I convert UTC time to specified time zone using SQL in SQL Server 2008 R2?

---------------------------------------------------

Scenario: I have a database/ASP.NET application that I use to manage people from quite a few different time zones. In order to keep activities coordinated, all the times in the database are UTC time. Each user's TimeZone is also registered in the database using .NET Framework time zoneIDs e.g. Eastern Standard Time.

In my query I want to specify a date and pull all the activities for that date. However, because all time stamps are UTC times, sometimes an individual's activies fall on two consecutive days in UTC time zone even though the individual completed them on the same day in his/her time zone. As a result, I get misleading data.

When I specify a date, I want that date to be considered user's date. That means, I need to convert all the activity time stamps into user's time zone in my query. This is where I can use some help.


Thanks, Sam

Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>