Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 database timezone

Author  Topic 

noamg
Posting Yak Master

215 Posts

Posted - 2010-11-17 : 02:35:53
hi,
I have a server with few databases. all the DBs have the same schemas. But each one works for other country.
the rows must include the local time of each country.
is their any way to config the DB for specific timezone ?
so the GETDATE() will return the local time.
thanks



Noam Graizer

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-11-17 : 02:53:09
The value that is returned by GETDATE() comes from the operating system of that computer so there is no chance that GETDATE() returns another result for each database.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2010-11-17 : 03:46:55
You could create a function in each DB that knows the offset from the Server Time, and returns local time for that DB.

-Chad
Go to Top of Page

noamg
Posting Yak Master

215 Posts

Posted - 2010-11-17 : 04:06:41
off course, this is application solution.
but, it their any system solution ?


Noam Graizer
Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2010-11-17 : 11:18:41
No, how could their be, the databases have no concept of what timezone they are in other than the timezone that the server is in.

-Chad
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-11-17 : 12:01:11
You should use GMT for the server's timezone and then use a SQL function to do the timezone conversion. If you search the forums here, you'll find my function udf_timezone_conversion. I turned it over to the development team to fix it for the new DST rules, so those are not included in the version I posted here. You'll need to update it or find someone who has updated it.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -