Alex Rivera | Logout

DateTime string parsing

Asked 2009-08-14T11:14:28.367
11

I have made a generic parser for parsing ascii files. When I want to parse dates, I use ParseExact function in DateTime object to parse, but I get problems with the year.

The text to parse is i.e. "090812" with the parseExact string "yyMMdd".

I'm hoping to get a DateTime object saying "12/8-2009", but I get "12/8-1909". I know, that I could make an ugly solution by parsing it afterwards, and thereby modifying the year..

Anyone know of a smart way to solve this ??

Thanks in advance..

Søren

Edit
Report

1 Answer

2

Well, if you're definite that all your source dates are this century, then you could use parseExact against a "20"-prefixed source string.

answered 2009-08-14T11:20:02.020

Your Answer