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

Posted by Madhuri123 under ASP.NET on 4/26/2011 | Points: 10 | Views : 18362 | Status : [Member] | Replies : 4
HI,

I am getting this error SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. . In my project i used 2 Datetimepicker control to retrieve data From Date to To Date.How can i avoid this




Responses

Posted by: Prabhakar on: 4/26/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi Madhuri..

i think you set Datetime . .
DateTime.MinValue and DateTime.MaxValue


DateTime.MinValue = 1/1/0001 12:00:00 AM

DateTime.MaxValue = 23:59:59.9999999, December 31, 9999,
exactly one 100-nanosecond tick
before 00:00:00, January 1, 10000


try it . .


Best Regard's
Prabhakar

Madhuri123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhuri123 on: 4/26/2011 [Member] Starter | Points: 25

Up
0
Down
i tried it but it is not working

Madhuri123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tijut2k on: 4/26/2011 [Member] Starter | Points: 25

Up
0
Down
use convert in insert statement like convert(datetime,dt,103) ........dt is your variable that hold the value of date at frontend


Best Regard's
Tiju Thankachan

Madhuri123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 4/26/2011 [Member] Starter | Points: 25

Up
0
Down
Hi

If you don't want to save any dates in database when datepicker control has novalue, change those columns to allow null,
In your program use a nullable datetime, and assign it when the datepicker control has some value ,

And don't pass it to database , so that it will be null

Madhuri123, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response