SQL Server Interview Question #60
What are common date and time functions in SQL Server?
SELECT, Filtering, Sorting & Built-in Functions Mid-Level Intermediate
Detailed Explanation
Common date/time functions include GETDATE, SYSDATETIME, GETUTCDATE, SYSUTCDATETIME, DATEADD, DATEDIFF, DATEPART, DATENAME, EOMONTH, and DATEFROMPARTS.
GETDATE returns the current server date/time as DATETIME, while SYSDATETIME provides higher precision as DATETIME2. Applications that operate across time zones commonly store timestamps in UTC and convert them appropriately at system boundaries.
Code Example
SELECT SYSDATETIME() AS ServerDateTime,
SYSUTCDATETIME() AS UtcDateTime,
DATEADD(DAY, 7, SYSDATETIME()) AS SevenDaysLater,
DATEDIFF(DAY, '2026-09-01', '2026-09-18') AS DaysDifference,
EOMONTH('2026-09-18') AS MonthEnd;