I have compiled the below code in c#
string datetime = String.Format("{0:MM/dd/yyyy hh:mm:ss tt}", root.SelectSingleNode("lasttime").InnerText);
lastUpdateTimestamp = DateTime.ParseExact(datetime, "MM/dd/yyyy hh:mm:ss tt", CultureInfo.CurrentCulture);
but in output i am getting lastUpdateTimestamp is 2/8/2013 7:00:24 AM instead of 02/08/2013 07:00:24 AM
Any idea what i am missing?
After getting this value i am running a query and getting this error
Invalid month in timestamp "2": cannot find leading zero [SQL query syntax invalid or unsupported.]
Hi All , i got the solution , Rather than passing lastUpdateTimestamp i am now taking date in a string variable and teking its value in proper format. Its working
root.SelectSingleNode("lasttime").InnerTextreturns a string.You are trying to use a DateTime format specifier to format a string.
Not sure what you are trying to do but something like this should work