SQL Azure Date and Time Functions derived from the Operating System

Transact-SQL includes a number of date and time functions that have values are derived from the operating system of the computer on which the instance of SQL Server is running. With SQL Azure these functions are all standardised on UTC (as you would expect) so you will receive the same result irrespective of the datacentre where the server is hosted. The table below shows the results from the following query run against a SQL Azure instance hosted in Northern Europe on 19th May 2010 12:06:04 UTC.

 SELECT
    SYSDATETIME() as SYSDATETIME,
    SYSDATETIMEOFFSET() as SYSDATETIMEOFFSET,
    SYSUTCDATETIME() as SYSUTCDATETIME,
    CURRENT_TIMESTAMP as currenttimestamp,
    GETDATE() as getdate,
    GETUTCDATE() as getUTCdate;

Query

SYSDATETIME()

2010-05-19 12:06:04.2422123

SYSDATETIMEOFFSET()

2010-05-19 12:06:04.2422123 +00:00

SYSUTCDATETIME()

2010-05-19 12:06:04.2422123

CURRENT_TIMESTAMP

2010-05-19 12:06:04.250

GETDATE()

2010-05-19 12:06:04.250

GETUTCDATE()

2010-05-19 12:06:04.240

Results from SQL Azure Database (time of query 19th May 2010 12:06:04 UTC)

The same results were returned from SQL Azure databases hosted in North Central US, South Central US and South East Asia.

Written by Michael Royster