Microsoft Docs

SYSDATETIME (Transact‑SQL)

The SYSDATETIME() function returns the current system date and time as a datetime2 value with a precision of 100 nanoseconds.

Syntax

SYSDATETIME ( )

Return type

datetime2(7)

Remarks

Examples

-- Example 1: Retrieve the current date and time
SELECT SYSDATETIME() AS CurrentDateTime;

-- Example 2: Get the date part only
SELECT CAST(SYSDATETIME() AS date) AS CurrentDate;

-- Example 3: Format as ISO 8601 string
SELECT CONVERT(varchar(33), SYSDATETIME(), 126) AS ISO8601String;

See also