Randolph West continues his SQL Server date & time data types series:
SQL Server 2008 introduced new data types to handle dates and times in a more intelligent way than the
DATETIMEandSMALLDATETIMEtypes that we looked at previously.This week, we look at the
DATETIME2data type. I’m not the first person to think that this was probably not the best name for a data type, but here we are, a decade later.
DATETIME2is, at its heart, a combination of theDATEandTIMEdata types we covered in previous weeks.DATEis 3 bytes long andTIMEis between 3 and 5 bytes long depending on accuracy. This of course means thatDATETIME2can be anything from 6 to 8 bytes in length.
Nowadays, if you want to store a date plus time, this should be your default, not DATETIME.