7

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?

2
  • 7
    What exactly is the purpose of doing this, if I may ask? Wouldn't a nullable datetime field be an easier sollution? Commented Jan 18, 2013 at 11:49
  • Not really sure if I understood you, but can't you do: DateTime sqlMinDateTime = new DateTime(1753, 01, 01); Commented Jan 18, 2013 at 11:56

1 Answer 1

18

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I don't understand the downvote. SqlDateTime has an implicit conversion to DateTime, I believe, so this should work just fine.
You need to use System.Data.SqlTypes.SqlDateTime.MinValue.Value, which is a DateTime.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.