SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SqlDateTime overflow


SqlDateTime overflow

Author
Message
jerry-621596
jerry-621596
Mr or Mrs. 500
Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)

Group: General Forum Members
Points: 593 Visits: 645
I use .NET 4.0 and they did not update the date range limits in the libraries to match the new range in SQL Sever. I will have to wait until I get home, but will try to find a workaround I came up with and post it here for you.

This was a one week research project for me so if I can find my fix it could save you a ton of time.
lonhanner
lonhanner
Valued Member
Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)Valued Member (61 reputation)

Group: General Forum Members
Points: 61 Visits: 144
Thanks so very much. It would look like MS would fix this.
I set my dates fields to "date" in sql and my time to "time(4)
jerry-621596
jerry-621596
Mr or Mrs. 500
Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)

Group: General Forum Members
Points: 593 Visits: 645
Different dev teams I guess. Not very efficient.
jerry-621596
jerry-621596
Mr or Mrs. 500
Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)Mr or Mrs. 500 (593 reputation)

Group: General Forum Members
Points: 593 Visits: 645
OK, just so everyone understands, this is not a SQL problem. The .NET Framework has a special data type for SQL databases in System.Data.SqlTypes.SqlDateTime. For some really silly reason, this data type's MinValue method has not been expanded to use the new minimum date. Probably because no one at Microsoft even thought about adding a SqlDateTime2 type, or any of the others like SqlDate and SqlTime.

What I had to do is find the code in my data access library that used SqlDateTime.MinValue to check dates before sending them to the database and changed it to use DateTime.MinValue. That will use the proper minimum date.

Do be sure and use DateTime2 in SQL or the database will be the next thing that will throw an error.

Hope this helps.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search