If you want to it directly from SQL you can create a function and call
that from your sql query

create function localtime (@gmtdate datetime, @timezoneoffset int)
returns datetime
As begin
    declare @localtime datetime
    select @localtime = dateadd(hh, -1 * @timezoneoffset, @gmtdate)
    return @localtime
end

Then it can be called like this

select localtime(getdate(), 3)

Tim

-----Original Message-----
From: cf-talk [mailto:[EMAIL PROTECTED]
Sent: Sunday, November 16, 2003 4:54 PM
To: CF-Talk
Subject: RE: Compensating for Server Time

Does that work in SQL 2000?

I've always used _javascript_ at logon to determine the time zone of the
user's computer.  I then store the time zone offset in a cookie or
session/client variable.  I then use a UDF to convert the time from the
SQL server to that user's local time.

If there was a way to do this all in one single shot via SQL as it seems
you have a solution for below I'd love to try it out.  Unfortunately I
can't seem to make the example you gave below work in SQL 2000.

-Novak

-----Original Message-----
From: Jochem van Dieten [mailto:[EMAIL PROTECTED]
Sent: Sunday, November 16, 2003 12:55 PM
To: CF-Talk
Subject: Re: Compensating for Server Time

Chris Montgomery wrote:
>
> What's the best way to compensate for time on a server in a hosted
> environment when the time is set to a different time than a user's
local
> time zone? Ex: client is in Central Time, server is on Eastern Time
(one
> hour ahead); client wants everything to reflect local time.

I use the AT TIME ZONE functionality from SQL, it even
compensates for daylight savings time:

testDB=> select '2003-12-31 12:00:00' AT TIME ZONE 'cet';
       timezone
---------------------
  2003-12-12 12:00:00

testDB=> select '2003-07-31 12:00:00' AT TIME ZONE 'cet';
       timezone
---------------------
  2003-06-12 11:00:00

Jochem

--
Who needs virtual reality
if you can just dream?
     - Loesje

  _____  


[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to