SQL Dates
Working with dates in SQL
Working with dates in SQL
Data types
Data types
DATETIME2
DATETIME2
DATETIME2 has more precision than DATETIME. It is recommended by Microsoft for new projects. There is a great write up here: DATETIME @ Database.guide.
Usage:
Can be used with or without a precision qualifier. No qualifier defaults to 7 digits in the millisecond/nanosecond segment.
DATETIME2
DATETIME2(7)
Converting SQL date format
Converting SQL date format
Selecting Part of a Date
Selecting Part of a Date