SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

date convertion to different time zone covering multiple location

By Partha Pal,

Here is the how to use the function

Note: As same time zone may cover multiple location, hence it needs to pass the location (other than 'UTC' and 'GMT') also along with time zone.
eg. EDT = Eastern DayLight Time covers North America as well as Australia hence it needs to call it as
dbo.ufnGetTZDateTime(<datetime needs to change>,<current timezone>,<current location>,<desired timezone>,<desired location>)

As our server is in IST Asia and if we need to convert the time to EDT, North America calling will be

select dbo.ufnGetTZDateTime(getdate(),'IST','Asia','EDT','North America')

select GETDATE() [Current IST Asia DateTime]
, dbo.ufnGetTZDateTime(getdate(),'IST','Asia','UTC',NULL) [Current UTC DateTime]
, dbo.ufnGetTZDateTime(getdate(),'IST','Asia','EDT','North America') [Current EDT North America DateTime]
, dbo.ufnGetTZDateTime(getdate(),'IST','Asia','EST','Australia') [Current EST Australia DateTime]
, dbo.ufnGetTZDateTime(getdate(),'IST','Asia','EDT','Australia') [Current EDT Australia DateTime]


Location can be get from TZLOCATION from TIME_ZONES table.

TimeZone can be found in TZCD, TZCDDL (TZCD are normal time zones, TZCDDL are Daylight time zones)from TIME_ZONES table

Total article views: 1143 | Views in the last 30 days: 2
Related Articles

Issues with Update DateTime column with GETDATE() using insert and delete triggers

Regarding Update DateTime column with GETDATE() using insert and delete triggers


Get the Current Date

Anything wrong with GetDate()?


select 21/(datediff(dd,getdate(),getdate())

select 21/(datediff(dd,getdate(),getdate())


GETDATE() remove Time

Remove the time value from GETDATE()


help using getdate function

help using getdate function