Error - SqlDateTime overflow Must be between 1 1 1753 12 00 00 AM and 12 31 9999 11 59 59 PM

0 votes

I've been using this piece of code I wrote, and it's functioning in the murkiest way possible. I want to add a row to the database that has two DateTime columns:

myrow.ApprovalDate = DateTime.Now
myrow.ProposedDate = DateTime.Now

When I update the database I receive this error:

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

I've even tried hard coding a value that was copied from the database into the object that was being updated:

// I copied this value from the DB
myrow.ApprovalDate =  Convert.ToDateTime("2008-12-24 00:00:00.000");

The weird thing is that the above approach worked for the initial insert to the database but failed moving forward. Still getting the same problem. Any ideas as to what's happening?

Sep 12 in Database by Kithuzzz
• 11,640 points
86 views

1 answer to this question.

0 votes

This works quite well for SQL min/max dates after many DB-related errors:

DateTime rngMin = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;

DateTime rngMax = (DateTime)System.Data.SqlTypes.SqlDateTime.MaxValue;

I hope this helps you.

answered Sep 13 by narikkadan
• 19,680 points

Related Questions In Database

0 votes
1 answer
0 votes
1 answer

Difference between single and double quotes in SQL

Single quotes are used to indicate the ...READ MORE

answered Sep 11, 2018 in Database by CodingByHeart77
• 3,720 points
16,938 views
0 votes
1 answer

Difference between clustered and non clustered index in SQL

The differences between the clustered and non ...READ MORE

answered Sep 28, 2018 in Database by Sahiti
• 6,380 points
949 views
+1 vote
1 answer

Difference between cross join and natural join

The cross join produces the cross product ...READ MORE

answered Oct 12, 2018 in Database by DataKing99
• 8,240 points
11,481 views
0 votes
0 answers
0 votes
1 answer

Authenticate on an ASP.Net Forms Authorization website from a console app

Essentially, we need to record a regular ...READ MORE

answered Sep 20, 2018 in IoT (Internet of Things) by Annie97
• 2,160 points
284 views
0 votes
1 answer

How to cache data in a MVC application?

Reference the System.Web dll in your model ...READ MORE

answered Oct 25, 2018 in Database by Frankie
• 9,830 points
1,018 views
0 votes
1 answer

What's the difference between VARCHAR and CHAR?

Any Unicode data can be stored in ...READ MORE

answered Sep 12 in Database by narikkadan
• 19,680 points
16 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP