SQL Server CURRENT_TIMESTAMP Function

The CURRENT_TIMESTAMP function in SQL Server retrieves the current date and time from the server's system clock. This is very useful for adding timestamps to your data or performing time-based calculations within your SQL queries.



CURRENT_TIMESTAMP: Definition and Usage

CURRENT_TIMESTAMP provides a way to get the exact date and time on the server where your database is running. This is important for tasks like logging events, recording when a record was created or modified, or generating time-sensitive reports. The function returns a datetime value in the format 'YYYY-MM-DD hh:mm:ss.mmm'.

Syntax

Syntax

CURRENT_TIMESTAMP
      

Technical Details

Return Type: datetime

Supported in:

  • SQL Server (starting with version 2008)
  • Azure SQL Database
  • Azure SQL Data Warehouse
  • Parallel Data Warehouse

Example

Retrieving the Current Timestamp

This query shows how to use CURRENT_TIMESTAMP to get the current date and time.

Syntax

SELECT CURRENT_TIMESTAMP;
      
Output

2024-11-29 16:33:47.123 (Example output; the actual time will vary)
      

Related Function

For getting the current date and time in UTC (Coordinated Universal Time), see the GETUTCDATE() function.


**Note:** The specific time shown in the example output will vary based on the server's system clock. The milliseconds (`.123`) portion of the output might have fewer digits depending on your SQL Server configuration.