I have a datetime column in SQL Server. I believe the minimum it can be is some date in 1753 or something. My Entity Framework POCO representing the table contains a DateTime. I'd like to set the datetime in the database to the minimum it can be set to. What's the easiest way to do this?
1 Answer
That value can be retrieved using the following property;
SqlDateTime.MinValue.Value
See http://msdn.microsoft.com/en-us/library/system.data.sqltypes.sqldatetime.minvalue.aspx for more details.
2 Comments
ta.speot.is
I don't understand the downvote.
SqlDateTime has an implicit conversion to DateTime, I believe, so this should work just fine.Stephen Byrne
You need to use System.Data.SqlTypes.SqlDateTime.MinValue.Value, which is a DateTime.
DateTime sqlMinDateTime = new DateTime(1753, 01, 01);