Earn income with your data and sql skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest self-service freelancing marketplace for people like you.

SQL CURRENT_TIMESTAMP Function

CURRENT_TIMESTAMP returns the current datetime on the database server.

This function can be used as a default value for a DATETIME column.

CURRENT_TIMESTAMP is equivalent to GETDATE.

Example

#

This example returns the current datetime on the database server.

 SELECT CURRENT_TIMESTAMP AS Now

Note: This function does not take brackets!

Result:  1 record
Now
2022-01-02 22:02:28.9763442

Syntax

Syntax of the CURRENT_TIMESTAMP function.

CURRENT_TIMESTAMP

Note: The CURRENT_TIMESTAMP function does not take brackets.


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

Note: The results differ in microsecond precision and timezone offset values.


You may also like



Earn income with your data and sql skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest self-service freelancing marketplace for people like you.

Guides


vsn 3.1