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, 2022 in Database by Kithuzzz
• 38,000 points
6,136 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.

To know more about SQL, It's recommended to join SQL Online Course today.

answered Sep 13, 2022 by narikkadan
• 63,600 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,750 points
29,629 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,370 points
1,841 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,250 points
16,585 views
0 votes
0 answers

SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified

I've been attempting to solve a significant ...READ MORE

Aug 22, 2022 in Database by Kithuzzz
• 38,000 points
1,679 views
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
932 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,844 views
0 votes
1 answer

How to solve : SQL Error: ORA-00604: error occurred at recursive SQL level 1

I saw the problem in the line ...READ MORE

answered Sep 10, 2022 in Database by narikkadan
• 63,600 points
4,970 views
0 votes
1 answer

Difference between EXISTS and IN in SQL?

Although the exists keyword can be used ...READ MORE

answered Sep 11, 2022 in Database by narikkadan
• 63,600 points
863 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP