datetime (data type)
data type datetime
What changes
- Input
- none
- Output or change
- none
Syntax at a glance
datetime
Work example
Read a legacy timestamp column while maintaining an existing contract.
Use datetime2 for new timestamp columns when an offset is not part of the stored value.
Check your work datetime rounds to coarse fractional-second increments and has a narrower range than datetime2.
Practice SQL
Open in SQL FlowSELECT CAST('2026-04-05T12:30:00' AS datetime) AS legacy_time;
Open Microsoft Learn for full syntax, permissions, and details for your version.