What exactly is datetime2?

.net c#-3.0 entity-framework sql sql-server-2008

Question

I've received this in an MSSQL 2008 INSERT statement.

System.Data.SqlClient.SqlException: The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.

1
27
7/19/2010 5:24:53 AM

Accepted Answer

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.

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

17
3/17/2009 7:54:58 PM

Popular Answer

Compared to.net datetime datatype, SQLServer's datetime datatype has a significantly narrower range of permitted values. The shortest number you can have with SQLServer's datetime type is 1/1/1753 since it essentially supports the gregorian calendar. 2008 saw the addition of a datetime2 datatype by SQLServer, which covers back to year 1. (there was no year 0). It seems that you are attempting to enter a datetime value earlier than January 1, 1753 into a datetime (not a datetime2) SQLServer column.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow