.net - I need to accept from input file and that may be of any format in C# . i need to check the format and extract year -
the format yyyymmdd not being accepted , throwing exception tried using
string year = datetime.parseexact(usedate, "yyyymmdd", cultureinfo.invariantculture).year.tostring();
do need use date variable ? , how date format yyyymmdd gets processed?
i have tested , works fine
datetime temp; if (datetime.tryparseexact("20130101", "yyyymmdd", cultureinfo.invariantculture, datetimestyles.none, out temp)) { string year = temp.year.tostring(); }
Comments
Post a Comment