Stuart McLachlan
stuart at lexacorp.com.pg
Thu Jul 17 17:58:35 CDT 2008
On 17 Jul 2008 at 9:06, Susan Harkins wrote:
> How do you specify that a date-time value should be UTC? I'm familiar with
> UTC, but not how to specify it in SQL Server.
It's an implementation, not a design issue.
For instance, WHEN YOU CREATE A DATE ENTRY, instead of USING GETDATE(), you
use GETUTCDATE(). Similarly you need another field to accompany each UTC
DateTime field which stores the current local time offset from UTC.
You can get the current local time offset (in minutes) like this:
DECLARE @UTCOffset INT
EXEC master..xp_regread
'HKEY_LOCAL_MACHINE',
'SYSTEM\CurrentControlSet\Control\TimeZoneInformation',
'ActiveTimeBias',
@UTCOffset OUTPUT
select @UTCOffset
In SQL Server 2008, there are new time zone aware data types so this will become
easier.