String was not recognized as a valid DateTime.
-
hi sir, i am trying to develop a application.but i have an issue.i have found this error when i am running my application on server.in stead of this when i am running this locally.there is no problem no error.and the database is also on server. when i run on server: when i enter datetime 01/02/2010(dd/MM/yyyy) it's working but when i change this like suppose 17/02/2010(dd/MM/yyyy) then this error occurred.while during save this date i am changing this format to MM/dd/yyyy format by following function. public string ChangeFormat(DateTime dtm, string format) { string str= dtm.ToString(format); return str; } and it's working.it can change the format.but error was same on server. please help me.as soon as possible.
-
hi sir, i am trying to develop a application.but i have an issue.i have found this error when i am running my application on server.in stead of this when i am running this locally.there is no problem no error.and the database is also on server. when i run on server: when i enter datetime 01/02/2010(dd/MM/yyyy) it's working but when i change this like suppose 17/02/2010(dd/MM/yyyy) then this error occurred.while during save this date i am changing this format to MM/dd/yyyy format by following function. public string ChangeFormat(DateTime dtm, string format) { string str= dtm.ToString(format); return str; } and it's working.it can change the format.but error was same on server. please help me.as soon as possible.
When you enter 01/02/2010 the system accepts the date as Jan 02, 2010 i.e. in MM/dd/yyyy format. So when you enter the date as 17/02/2010 it is unable to accept it since 17 is not a valid month.
-
When you enter 01/02/2010 the system accepts the date as Jan 02, 2010 i.e. in MM/dd/yyyy format. So when you enter the date as 17/02/2010 it is unable to accept it since 17 is not a valid month.
yes sir, i am agree with you sir.but sir i am changing date to MM/dd/yyyy format.with the help of function.and it is right on locally while on server.it gives that error.
-
yes sir, i am agree with you sir.but sir i am changing date to MM/dd/yyyy format.with the help of function.and it is right on locally while on server.it gives that error.
Are pointing to the same database from both your local development system and the server? If not check the date format on the server's database. probably it uses a different date format from your development server.
-
Are pointing to the same database from both your local development system and the server? If not check the date format on the server's database. probably it uses a different date format from your development server.
hi sir, i want to convert my dd-MM-yyyy to yyyy-MM-dd. and i am using ToString("yyyy-MM-dd") but it return yyyy-dd-MM. please help me. thanks
-
hi sir, i want to convert my dd-MM-yyyy to yyyy-MM-dd. and i am using ToString("yyyy-MM-dd") but it return yyyy-dd-MM. please help me. thanks
Did you check the server's datetime format. The way date is treated depends on the systems' regional settings. Check what is the default date format? dd-MM-yyyy or MM-dd-yyyy
-
Did you check the server's datetime format. The way date is treated depends on the systems' regional settings. Check what is the default date format? dd-MM-yyyy or MM-dd-yyyy
Just use split function of string and concatenate it !!!!!!!....I think this may help you.
-
Just use split function of string and concatenate it !!!!!!!....I think this may help you.
I think you need to post the message to the original question. The original author would not have got your reply.
-
I think you need to post the message to the original question. The original author would not have got your reply.
hi sir, actually server datetime format is yyyy-MM-dd so that's why i want to convert my dd-MM-yyyy format to yyyy-MM-dd. and for this i am using str.ToString("yyyy-MM-dd").but this was not working. i am unable to understand why it converts in yyyy-dd-MM. please help me for this conversion. thanks,
-
hi sir, actually server datetime format is yyyy-MM-dd so that's why i want to convert my dd-MM-yyyy format to yyyy-MM-dd. and for this i am using str.ToString("yyyy-MM-dd").but this was not working. i am unable to understand why it converts in yyyy-dd-MM. please help me for this conversion. thanks,
You have to consider 2 settings here - 1. Date time setting on the IIS server - Affects the format in the appl 2. Date time setting on the Database - Affects the format that is stored in the database. Now, as per our exchanges I understand that your database datetime format is "yyyy-MM-dd" and your application server's date time format is "MM-dd-yyyy". Your application server is expecting you to pass dates in the format "MM-dd-yyyy", whereas you are sending the date in the format "dd-MM-yyyy". That is why you are facing the following issues - 1. When passing 17-02-2010 [Feb 17, 2010] application throws error. 2. When passing 01-02-2010 [Feb 01, 2010] application converts it to 2010-01-02 The trouble here is that your development machine has local date time settings set to "dd-MM-yyyy" whereas your application server has the date time setting set as "MM-dd-yyyy" hence you are having trouble visualizing and replicating the error in development. I would suggest, when you first load the date to your date time variable, you split the text as date, month and year and use the date functions to generate the date based on these inputs instead of passing it as one date value. This would ensure that the date values remain consistent across servers with different date time format settings. Hope this makes sense and helps!! :)
-
hi sir, actually server datetime format is yyyy-MM-dd so that's why i want to convert my dd-MM-yyyy format to yyyy-MM-dd. and for this i am using str.ToString("yyyy-MM-dd").but this was not working. i am unable to understand why it converts in yyyy-dd-MM. please help me for this conversion. thanks,
-
hi sir, i am trying to develop a application.but i have an issue.i have found this error when i am running my application on server.in stead of this when i am running this locally.there is no problem no error.and the database is also on server. when i run on server: when i enter datetime 01/02/2010(dd/MM/yyyy) it's working but when i change this like suppose 17/02/2010(dd/MM/yyyy) then this error occurred.while during save this date i am changing this format to MM/dd/yyyy format by following function. public string ChangeFormat(DateTime dtm, string format) { string str= dtm.ToString(format); return str; } and it's working.it can change the format.but error was same on server. please help me.as soon as possible.
AS an example try like this to correctly format your dates: Create a web form with 2 labels named lblDateGB and lblDateUS then run the folowing code in the Page Load event:
string dateGB = DateTime.Now.ToString();
lblDateGB.Text = dateGB;CultureInfo info = new CultureInfo("en-US");
DateTime dateUS = DateTime.Parse(dateGB, info);
lblDateUS.Text = dateUS.ToString();Note that based on your post the server is defaulted to a US style date so the above should work. The crux is that you are converting the date using a specific culture that matches the server culture so, as long as the original date is a valid date, this should convert it correctly.