I have 2 databases on the same SQL Server. Is it possible to have one in PST and the other in EST?
-
7Wouldn't it be better to have them *both* as UTC? – Greg Hewgill Apr 02 '12 at 19:15
2 Answers
No, The date/time is derived from the operating system of the computer on which the instance of SQL Server is running.
You could however have a custom UDF that you would call instead of getdate() and then do the timezone change in that UDF. You can also assign default values to columns with something like this
CREATE TABLE Test (Val DATETIME DEFAULT dateadd(hh,-3,GETDATE()))
Now when you do an insert it will use the default
INSERT test DEFAULT VALUES
SELECT * FROM test
....this of course won't work on updates and also someone could update that value
If you want to use GMT then use GETUTCDATE
SELECT GETUTCDATE()

- 132,095
- 25
- 206
- 225
This does not account for daylight savings time. The only way this can be accomplished is by having a table for the time zones as this example. https://github.com/mattjohnsonpint/SqlServerTimeZoneSupport
In newer SQL versions it's a lot easier but in older versions (2014 or older) there is no straightforward way to accomplish this.

- 53
- 1
- 8