65.9K
CodeProject is changing. Read more.
Home

Validating Dates in dd-MMM-yyyy format

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.98/5 (31 votes)

May 13, 2010

CPOL
viewsIcon

26159

This is an alternative to "Validating Dates in dd-MMM-yyyy format"

Less magic, more readable, would be:

DateTime dt1;
DateTime dt2;
if (DateTime.TryParseExact(str1, "dd-MMM-yyyy", null, DateTimeStyles.None, out dt1) &&
    DateTime.TryParseExact(str2, "dd-MMM-yyyy", null, DateTimeStyles.None, out dt2)) {
	// do something with those datetimes
}