Getting Current Time in Local Time Zone - SQL Server


When running on a SQL Server whose local clock is in UTC, the GETDATE() function returns a value in UTC. This article provides a means to convert that timestamp into whatever timezone is desired. Note that it doesn't handle time zones that are a fractional number of hours offset from UTC, but the query below can easily be adapted to support this scenario.

Sample Code

declare @tzo int

select @tzo = convert(int, substring(current_utc_offset,1,3)) * 60 from sys.time_zone_info where name = 'Eastern Standard Time'

SELECT DT = dateadd(minute, @tzo, GETUTCDATE())