What is the difference between DATETIME and DATETIME2?
Quick Answer
DATETIME is the legacy type: range from 1753, precision rounded to ~3.33 ms, 8 bytes. DATETIME2 is the modern replacement: range from year 1, precision to 100 ns (configurable, DATETIME2(3) is 7 bytes), ANSI-compliant. Use DATETIME2 for new columns; use DATETIMEOFFSET when you need the timezone offset.
DATETIME is the old type — it only goes back to 1753, its precision is rounded to about three milliseconds, and it's eight bytes. DATETIME2 is the one to use now: wider range, precision you can configure down to 100 nanoseconds, and it can actually be smaller on disk if you pick a lower precision. For new columns I use DATETIME2, store times in UTC, and reach for DATETIMEOFFSET only when I genuinely need the timezone offset preserved. And I use SYSUTCDATETIME() rather than GETUTCDATE() so I'm not mixing types.
DATEandTIMEexist separately since 2008.DATETIMEOFFSETstores the offset from UTC — best for globally distributed apps; otherwise store UTC in aDATETIME2and convert in the app.- Functions:
SYSDATETIME()/SYSUTCDATETIME()returnDATETIME2;GETDATE()/GETUTCDATE()return the oldDATETIME. - Mixing
DATETIMEandDATETIME2in comparisons causes implicit conversion — pick one type per column and stick to it.