DATETIME2 vs DATETIME
DATETIME2 vs DATETIME is a SQL function in the Date/Time Functions category. SQL Server: DATETIME2 (2008+) has higher precision and date range. DATETIME is legacy. The syntax is DATETIME2(precision) vs DATETIME. It accepts precision. It returns dateTime comparison. A typical example: CREATE TABLE events ( legacy_time DATETIME, precise_time DATETIME2(7), precise_ms DATETIME2(3) ); INSERT INTO events VALUES ('2026-06-06 14:30:00.123', '2026-06-06 14:30:00.1234567', '2026-06-06 14:30:00.123'); -- DATETIME: Range 1753-9999, precision ~3.33ms -- DATETIME2: Range 0001-9999, precision 100ns (7 decimals) -- DATETIME2 advantages: -- - Higher precision (.1234567 vs .123) -- - Wider date range -- - Uses less storage (6-8 bytes vs 8 bytes) -- - ANSI compliant (DATE, TIME, DATETIME2 are SQL standard)… A close relative is NOW(), which returns the current date and time as a timestamp. A close relative is CURDATE(), which returns the current date without time. A close relative is DATE(), which extracts the date part from a datetime expression.