SYSDATETIME
SYSDATETIME is a built‑in function in SQL Server that returns the current system date and time. It provides the server’s local date and time with high precision by returning a value of type datetime2(7), which includes up to 100 nanoseconds of fractional seconds. The function is non-deterministic because its result depends on the moment it is executed and the server’s clock.
SYSDATETIME reflects the server’s local time and is commonly used for time stamping, logging, and other scenarios
- GETDATE(): returns the current date and time as a datetime with lower precision.
- SYSUTCDATETIME(): returns the current date and time in UTC, as datetime2(7).
- SYSDATETIMEOFFSET(): returns the current date and time with time zone offset, as datetimeoffset(7).
- GETUTCDATE(): returns the current UTC date and time as datetime.
SYSDATETIME is introduced in SQL Server 2008 and is part of the family of functions used to