Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friend,
in my project so many date time pickers is there.If i'm using standard format itz working all days. But if i'm using custom format and i selected future date i got this error.

Error:
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.


please solve my problem.


Thanks & Regards
Posted
Updated 28-Mar-16 22:32pm
v2

According to the documentation[^] The DateTime value type represents dates and times with values ranging from 12:00:00 midnight, January 1, 0001 Anno Domini (Common Era) through 11:59:59 P.M., December 31, 9999 A.D. (C.E.).

What is the content of the string that you are trying to convert?
 
Share this answer
 
What is custom format you have used ?

this error comes in two scenarios,

1) when you try to convert to out of limit date which is year 0001 to 9999

2) when you try to convert to any invalid date (like to month 14, or date 32).

in most of the cases the second scenario is the culprit, check your date format, even consider your culture.


mark as answer if helped you.
 
Share this answer
 
Comments
Hari Krishna Prasad Inakoti 22-Sep-11 9:32am    
i'm using this format dd-MM-yy(Indian format)only.i gave future date of this month only .
Hari Krishna Prasad Inakoti 23-Sep-11 5:38am    
Actually i'm using datetime picker in form.cs
while inserting sql query like " '"dtpname.text"' ", is working and values inserted into sql database.
But, the same form while updating with future date is not working, It's saying that ""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."".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900