The built-in functions GETDATE
and GETUTCDATE
each return the current date and time without a time zone offset.
The return value of both functions is based on the operating system of the computer on which the instance of SQL Server is running.
The return value of GETDATE represents the current time in the same timezone as operating system. The return value of GETUTCDATE represents the current UTC time.
Either function can be included in the SELECT
clause of a query or as part of boolean expression in the WHERE
clause.
Examples:
-- example query that selects the current time in both the server time zone and UTC
SELECT GETDATE() as SystemDateTime, GETUTCDATE() as UTCDateTime
-- example query records with EventDate in the past.
SELECT * FROM MyEvents WHERE EventDate < GETDATE()
There are a few other built-in functions that return different variations of the current date-time:
SELECT
GETDATE(), --2016-07-21 14:27:37.447
GETUTCDATE(), --2016-07-21 18:27:37.447
CURRENT_TIMESTAMP, --2016-07-21 14:27:37.447
SYSDATETIME(), --2016-07-21 14:27:37.4485768
SYSDATETIMEOFFSET(),--2016-07-21 14:27:37.4485768 -04:00
SYSUTCDATETIME() --2016-07-21 18:27:37.4485768