Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GMT and local time conversion

Status
Not open for further replies.

JChanana

MIS
May 14, 2001
3
US
Is there a way in SQL Server to convert GMT time to a local time by designating a time zone. I do not want to convert to the antive time zone but identifya time zone to conver to. I believe GMDATE convert to GMT, I need to convert from GMT to local time given time zone (this needs to take into account whether daylight savings is applicable or not). Is this even possible? Is there another way?
 
not sure if there's anything 'built-in'. i created my own function in sql2000. this might work for you:
create function localtime
(@gmtdate datetime, @timezoneoffset int)
returns datetime
as
begin
declare @localtime datetime
select @localtime = dateadd(hh, -1 * @timezoneoffset, @gmtdate)
return @localtime
end

you can call the function like this:
dbo.localtime(@timestamp, @timezoneoffset)

note: the @timezoneoffset is the number of hours the local time deviates from GMT time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top