Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
String was not recognized as a valid DateTime.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: String was not recognized as a valid DateTime.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[FormatException: String was not recognized as a valid DateTime.]
System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +2850658
System.Convert.ToDateTime(String value) +98
RenewalPayment.btnSaveRenewalPayment_Click(Object sender, EventArgs e) +1413
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
Posted
Updated 12-Sep-13 20:43pm
v2
Comments
TrushnaK 13-Sep-13 1:53am    
String was not recognized as a valid DateTime. It describes itself that you passing wrong datetime.

can you post your code what you done so far?
Thanks7872 13-Sep-13 1:53am    
So we are suppose to assume everything regarding the strings etc?
[no name] 13-Sep-13 1:59am    
Here is the code : http://steasylicense.com/frmRenewalPayment.txt
Sergey Alexandrovich Kryukov 13-Sep-13 2:00am    
At least tell us what's the value of the string your are trying to parse as DateTime.
—SA
[no name] 13-Sep-13 2:01am    
MM/DD/YYYY

I would suggest you to use CAST and CONVERT[^] functions. Sometimes it is needed to use SET DATETIMEFORMAT[^] statement.
 
Share this answer
 
 
Share this answer
 
Comments
Maciej Los 13-Sep-13 3:11am    
This is not an answer. Please, delete it to avoid down-voting.
I change .net globalization from IIS and set to english (US)
 
Share this answer
 
Comments
Maciej Los 13-Sep-13 3:11am    
This is not an answer. Please, delete it to avoid down-voting.

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



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