Sunday, July 18, 2010

DateTime MinValue in SQL SERVER and C#

I was trying to store C# DateTime.MinValue in SQL SERVER and got the following exception

SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.

In SQL Server the minimum date that can be stored in a datetime field (1753/1/1), is not equal to the MinValue of the DateTime .NET data type (0001/1/1).

Therefore if your datetime value is DateTime.MinValue then don't save it in SQL SERVER.

No comments:

Post a Comment