T-SQL Tutorial

Datetime - TSQL Tutorial


On Transact SQL language the datetime is part of date and time data types and define a date that is combined with a time of day with fractional seconds.

Datetime syntax:

datetime

PropertyValue
RangeJanuary 1, 1753, through December 31, 9999
Length19 minimum - 23 maximum
Storage size8 bytes
CalendarGregorian

Datetime example:

USE model;
GO
DECLARE @date date= '08-21-14';
DECLARE @datetime datetime = @date;
SELECT @datetime AS 'Datetime', @date AS 'Date';
GO

DatetimeDate
2014-08-21 00:00:00.0002014-08-21