Link to home
Start Free TrialLog in
Avatar of Sh M
Sh MFlag for United States of America

asked on

SQL date and time and different time zone

Hi,
I have a .net application using SQL 2000 database. the application and DB is running on a server in US and therefore saving the time and date using US time. Being nearly one day in front of US time, I need to convert the dates to our time zone. In the database table the function getdate() is used for a date column. how can I modify it so I could save the date in the table using our time zone when data are submitted?

Thanks in advance

Avatar of Ted Bouskill
Ted Bouskill
Flag of Canada image

You only have two choices for the current date.  GETDATE() and GETUTCDATE() which have to be converted into any other zones.  You can use DATEADD()

DATEADD(day, 1, GETDATE()) will add one day onto the current date.  You can use negative values as well.
ASKER CERTIFIED SOLUTION
Avatar of Wizilling
Wizilling
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wizilling makes a good point and something I forgot to add.  All systems I design store dates as UTC and then I convert to local time zones.  Even with web applications you can convert the time zone at the client side using JavaScript.  It eliminates a LOT of headaches.

Sadly I work at a large multi-national firm whose headquarters are in California.  So guess which time zone is the default? (SIGH) Yes PST.  So I often fix many bugs with date math issues due to some process misinterpreting the date time zone because the a developer assumed that the date was in their time zone.