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

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -