Welcome to The Forum SA. As a visitor you have read only access to the public content areas of this website. You will have to register as a member to access all content, post messages and network with our members. Membership is free and registering is quick and easy. You can click here to register now and become a member within minutes.
message string was not recognized as a valid datetime. pastel
Use DateTime.ParseExact.- Converts the specified string representation of a date and time to its DateTime equivalent using the specified format and culture-specific format information. The format of the string representation must match the specified format exactly. ParseExact and TryParseExact allows to use a custom format string.
DateTime date = DateTime.ParseExact(strDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
The IFormatProvider parameter specifies the culture to use to parse the date. Unless your string comes from the user, you should pass CultureInfo.InvariantCulture. If the string does come from the user, you should pass CultureInfo.CurrentCulture, which will use the settings that the user specified in Regional Options in Control Panel.
I think I have found the 'hack' that works for me.
I make sure the date collum is formatted to 'date - English (Australia).
Sometimes I still get this date error when I try to import the CSV file, then I have found that after saving the CSV, the changes revert back to 'general'. I have no idea why, or how to fix this as the settings continue to revert back after multiple attempts to resave.
So, then I take the date from the 'error giving CSV' and insert those date lines into a spreadsheet that I know does not give the error. I then make sure the date is in the correct format and delete the original un-needed data and resave. This seems to work and I am then able to import the data that I need.
Not a very scientific or IT answer, but it does seem to work.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, personalize advertising, and to analyze site activity. We may share certain information about our users with our advertising and analytics partners. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment