SQL GETUTCDATE Function

GETUTCDATE returns the current datetime on the database server.

The returned value represents current time in the UTC timezone.

GETUTCDATE can be used as the default value for DATETIME columns.

Example

#

This example returns the current UTC datetime on the database server.

SELECT GETUTCDATE() AS 'UTC Now'
Result:  1 record
UTC Now
2021-12-02 21:05:58.3260297

Syntax

Syntax of the GETUTCDATE function.

GETUTCDATE()

System Datetime

SQL Server supports 6 system datetime functions.

 SELECT CURRENT_TIMESTAMP AS 'CURRENT_TIMESTAMP',
        SYSDATETIME() AS 'SYSDATETIME',
        SYSDATETIMEOFFSET() AS 'SYSDATETIMEOFFSET',  
        SYSUTCDATETIME() AS 'SYSUTCDATETIME', 
        GETDATE() AS 'GETDATE',
        GETUTCDATE() AS 'GETUTCDATE'
Result:
Function Result
CURRENT_TIMESTAMP 2021-09-12 18:14:15.007
SYSDATETIME() 2021-09-12 18:14:15.0077586
SYSDATETIMEOFFSET() 2021-09-12 18:14:15.0077586 -05:00
SYSUTCDATETIME() 2021-09-12 23:14:15.0077586
GETDATE() 2021-09-12 18:14:15.007
GETUTCDATE() 2021-09-12 23:14:15.007

The results differ in microsecond precision and datetime offset values.


You may also like



Guides


vsn 3.1