Trouble parsing string to date c# (from sqlite database) -


i modeled solution on answers many other posts still not work.

public void dtparsing() {     string date = "2016-04-19 15:14:19.597";     console.writeline("date c# string : {0} : ", date);     string pattern = "yyyy-m-d h:m:s.f";     datetime mydate = datetime.parseexact(date, pattern, null);     console.writeline("\ndate c# datetime : {0} : ", mydate.tostring());     console.readkey(); } 

one problem values not set number of digits: milliseconds can anywhere 0 3 digits. there solution without parsing more manual parsing?

this should stop error (no need pattern, must match exactly)

datetime mydate = convert.todatetime(date); 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -