Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of the following SQL Server declaration: datetime2(7)?

People also ask

What is DATETIME2 7 SQL Server?

The DateTime2 is an SQL Server data type, that stores both date & time together. The time is based on the 24 hours clock. The DateTime2 stores the fractional seconds Up to 7 decimal places (1⁄10000000 of a second). The Precision is optional and you can specify it while defining the DateTime2 column.

What is DATETIME2 data type in SQL Server?

Defines a date that is combined with a time of day that is based on 24-hour clock. datetime2 can be considered as an extension of the existing datetime type that has a larger date range, a larger default fractional precision, and optional user-specified precision.

What is datetime and DATETIME2 in SQL Server?

DATETIME2 has a date range of "0001 / 01 / 01" through "9999 / 12 / 31" while the DATETIME type only supports year 1753-9999. Also, if you need to, DATETIME2 can be more precise in terms of time; DATETIME is limited to 3 1/3 milliseconds, while DATETIME2 can be accurate down to 100ns. Both types map to System.

What is the difference between datetime and DATETIME2 7?

Datetime2 has fractional seconds precision of 7 which means that there are 7 digits representing the nanosecond value whereas DateTime has a precision of 3. The following example demonstrates the fractional seconds rounding off.


datetime2 [ (fractional seconds precision) ]

It's the fractional seconds precision according to the MSDN documentation.

http://msdn.microsoft.com/en-us/library/bb677335.aspx

This is the microsoft example of 4:

DECLARE @datetime2 datetime2(4) = '12-10-25 12:32:10.1234';

So I would assume that 7 would be:

DECLARE @datetime2 datetime2(7) = '12-10-25 12:32:10.1234567';