I am using Datetime.Minvalue which return 1.1.0001. This value can not be stored to DB because year is smaller than 1975.
Is it possible to override DateTime.Minvalue to 1.1.1901?
Regards
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, it’s not. You could instead use SqlDateTime.MinValue (1753-01-01), define your own constant for 1901-01-01 if that’s what you want to use, or actually use a nullable DateTime:
In the instance where no date is specified, a null may make more sense and persist DBNull.Value to the database instead of a “special” value like you’re currently doing.
Or, as a final option….at the point you come to persist to the database, do a check for DateTime.MinValue and switch in an alternative. But I’d recommend the nullable DateTime.