c# - Parsing Datetime as yyyy-MM-dd H:mm:ss -


my stringquery returns datetime value in following format 08/05/2015 15:21:40, extract parse datetime in following format - yyyy-mm-dd h:mm:ss datetime type.

i have tried following code variations convert variable keeps returning datetime 08/05/2015 15:21:40, instead of 2015-05-08 15:21:40

   var stringquery = (from p in db.database_cre_events                     select new loan()                     {                         cdate = p.lastupdated                      }).firstordefault();          if (stringquery != null && stringquery.cdate.hasvalue)        {                           var ott = stringquery.cdate.value;            tt = ott.tostring("yyyy-mm-dd h:mm:ss zzz");            //format = dtt.tostring("yyyy-mm-dd h:mm:ss");            //convert = datetime.parseexact(inp, "yyyy-mm-dd h:mm:ss", provider);         }         convert = datetime.parseexact(tt, "yyyy-mm-dd h:mm:ss zzz", new cultureinfo("en-us")); 

please advice further, may going wrong? many thanks

but convert variable keeps returning datetime 08/05/2015 15:21:40, instead of 2015-05-08 15:21:40

convert of type datetime. it irrespective of format. seeing debugger showing date in specific format.

datetime stored number (ticks), format presentation purpose.

i not sure why trying convert datetime object string first, , parsing datetime, use original datetime object , use string format wherever need display it.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -