Reputation: 3927
I have string value 7/29/2000
. When I convert it to date time it's giving an error. Error Message: Cannot convert string to Datetime
IFormatProvider provider = new System.Globalization.CultureInfo("en-US", true);
string oldValue = decrypt.Decrypt(dtOldI9Value.Rows[0][column.ColumnName].ToString().Trim());
DateTime dtOldValue = DateTime.Parse(oldValue, provider, System.Globalization.DateTimeStyles.NoCurrentDateDefault);
From the 3 rd line i am getting the value as "7/29/2000". Please help me.
Upvotes: 0
Views: 228
Reputation: 151594
This works:
IFormatProvider provider = new System.Globalization.CultureInfo("en-US", true);
DateTime dtOldValue = DateTime.Parse("07/29/2000", provider, System.Globalization.DateTimeStyles.NoCurrentDateDefault);
Console.WriteLine(dtOldValue);
So there must be something with your decrypt.Decrypt()
. Are you sure it doesn't adds characters to oldValue
? Check oldValue.Length
, it should be 10.
Upvotes: 3