AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
Posted by RAJESH KUMAR VISHWAKARMA on  9/19/2009 12:37:23 AM Category: Asp.Net 2.0
Add to my favorites
Email to friend
i am using datepicker in asp.net 2.0 thruough ur dll but there is some problem to insert in data i sql Table.

Error Is coming after clicking button "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

The statement has been terminated.
"
if i use command in Sql insert into DatePicker values('Rajesh','31/10/2009') then giving same Error
As Above.

If i use command insert into DatePicker values('Pravin','2009/12/19') or ('Pravin','2009-12-19') it is running successfully!

Plese Sovle my problem .
Thanks!
Rajesh


Post Your Reply Post New Question

 Viewer's Reply
dd/MM/yyyy does not support in sql
Answered By Moderator1 on 9/20/2009 9:45:21 PM
Hi,

The sql server does not support dd/MM/yyyy date formats. Its default date format is yyyy-MM-yy.

The way you are passing the parameter, the SQLCommand does not know to interpret or convert the given value to sql compatible format. So you have to explicitly convert your input as default sql server date format as below

string inputDate="31/12/2009";
values ('Rakesh', " + Convert.ToDateTime(inputDate).ToString("yyyy-MM-dd") ...

something like this.. Please try..
 
converting char to datetime
Answered By NDABASEGETSE on 10/30/2012 4:44:58 AM
thank you for your help
 
converting char to datetime
Answered By NDABASEGETSE on 10/30/2012 4:47:59 AM
thank you for your help brother
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
Simply JavaScript - Free 150 Page Preview!
Simply SQL - Free 111 Page Preview!
Washington Technology