Andrej Tozon's blog

In the Attic

NAVIGATION - SEARCH

Parsing dates

A rediscovered oldie: when dealing with some old, legacy code, you could find yourself wrestling with very oddly formatted data. One of the more common types the .NET framework can easily help you with, are the date/time values. For example, to convert string value of "890712" to a proper date, simply use

DateTime date = DateTime.ParseExact("890712", "yyMMdd", null)

which would result in 12.7.1989 or 7/12/1989.