Skip to content

Latest commit

 

History

History
133 lines (102 loc) · 4.89 KB

current-date-transact-sql.md

File metadata and controls

133 lines (102 loc) · 4.89 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic ms.custom f1_keywords helpviewer_keywords dev_langs monikerRange
CURRENT_DATE (Transact-SQL)
CURRENT_DATE returns the current database system date as a date value, without the database time and time zone offset.
PratimDasgupta
prdasgu
randolphwest
08/08/2024
sql
t-sql
reference
ignite-2024
CURRENT_DATE
CURRENT_DATE_TSQL
dates [SQL Server], functions
niladic functions
current date and time [SQL Server]
time [SQL Server], current
date and time [SQL Server], CURRENT_DATE
functions [SQL Server], time
system date and time [SQL Server]
system date [SQL Server]
functions [SQL Server], date and time
time [SQL Server], functions
dates [SQL Server], current date and time
dates [SQL Server], system date and time
CURRENT_DATE function [SQL Server]
time [SQL Server], system
TSQL
>=aps-pdw-2016 || =azuresqldb-current || =azuresqldb-mi-current

CURRENT_DATE (Transact-SQL)

[!INCLUDE asdb-asdbmi]

In [!INCLUDE ssazure-sqldb] and [!INCLUDE ssazuremi-md], this function returns the current database system date as a date value, without the database time and time zone offset. CURRENT_DATE derives this value from the underlying operating system on the [!INCLUDE ssde-md] runs.

Note

SYSDATETIME and SYSUTCDATE have more precision, as measured by fractional seconds precision, than GETDATE and GETUTCDATE. The SYSDATETIMEOFFSET function includes the system time zone offset. You can assign SYSDATETIME, SYSUTCDATETIME, and SYSDATETIMEOFFSET to a variable of any of the date and time types.

This function is the ANSI SQL equivalent to CAST(GETDATE() AS DATE). For more information, see GETDATE.

See Date and time data types and functions for an overview of all the [!INCLUDE tsql] date and time data types and functions.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

[!INCLUDE ssazure-sqldb] and [!INCLUDE ssazuremi-md] only:

CURRENT_DATE

Arguments

This function takes no arguments.

Return types

date

Remarks

[!INCLUDE tsql] statements can refer to CURRENT_DATE anywhere they can refer to a date expression.

CURRENT_DATE is a nondeterministic function. Views and expressions that reference this column can't be indexed.

Examples

These examples use the system functions that return current date and time values, to return the date, the time, or both. The examples return the values in series, so their fractional seconds might differ. The actual values returned reflect the actual day / time of execution.

A. Get the current system date and time

SELECT SYSDATETIME(),
    SYSDATETIMEOFFSET(),
    SYSUTCDATETIME(),
    CURRENT_TIMESTAMP,
    GETDATE(),
    GETUTCDATE(),
    CURRENT_DATE;

Note

CURRENT_DATE (Transact-SQL) is available in [!INCLUDE ssazure-sqldb] and [!INCLUDE ssazuremi-md] only.

[!INCLUDE ssresult-md]

Data type Value
SYSDATETIME() 2024-06-26 14:04:21.6172014
SYSDATETIMEOFFSET() 2024-06-26 14:04:21.6172014 -05:00
SYSUTCDATETIME() 2024-06-26 19:04:21.6172014
CURRENT_TIMESTAMP 2024-06-26 14:04:21.617
GETDATE() 2024-06-26 14:04:21.617
GETUTCDATE() 2024-06-26 19:04:21.617
CURRENT_DATE 2024-06-26

B. Get the current system date

SELECT CONVERT(DATE, SYSDATETIME()),
    CONVERT(DATE, SYSDATETIMEOFFSET()),
    CONVERT(DATE, SYSUTCDATETIME()),
    CONVERT(DATE, CURRENT_TIMESTAMP),
    CONVERT(DATE, GETDATE()),
    CONVERT(DATE, GETUTCDATE()),
    CURRENT_DATE;

Note

CURRENT_DATE (Transact-SQL) is available in [!INCLUDE ssazure-sqldb] and [!INCLUDE ssazuremi-md] only.

[!INCLUDE ssresult-md]

Data type Value
SYSDATETIME() 2024-06-26
SYSDATETIMEOFFSET() 2024-06-26
SYSUTCDATETIME() 2024-06-26
CURRENT_TIMESTAMP 2024-06-26
GETDATE() 2024-06-26
GETUTCDATE() 2024-06-26
CURRENT_DATE 2024-06-26

Related content