Home » SQL CURRENT_TIMESTAMP

SQL CURRENT_TIMESTAMP

SQL Server CURRENT_TIMESTAMP function returns the current date and time.





It returns the date and time from the operating system of the computer that the instance of SQL Server is running on and the format of date is ‘yyyy-mm-dd hh:mi:ss.mmm’.

It is more similar to SQL Getdate() Function.

Syntax

CURRENT_TIMESTAMP 

There are no argument for this function .

Lets look at an example of CURRENT_TIMESTAMP in SQL Server.

Following statement uses CURRENT_TIMESTAMP function and returns current date and time of system.

SELECT CURRENT_TIMESTAMP AS [CurrentDateTime]

As you can see, It returns the current date and time of system.

You can also get a day and month from CURRENT_TIMESTAMP() function.

Get a day and month from CURRENT_TIMESTAMP() function

Following statement returns a date part that is a day and month from date returned by  CURRENT_TIMESTAMP() function returns current date and time of system.

SELECT CURRENT_TIMESTAMP AS [CurrentDateTime], 
DAY(CURRENT_TIMESTAMP ) AS [CurrentDay], 
MONTH(CURRENT_TIMESTAMP ) AS [CurrentMonth]

As you can see, it returns a DAY and MONTH of current date. Here we have used a DAY, and MONTH function with CURRENT_TIMESTAMP function to day and month value from date.

 

Recommended for you

Getdate() function

Datepart()




Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.