Data Regex Validation

-1

Good Morning ...

I'd like to know how I can validate a date! Where the Final Date can not be less than the Start Date (dataFinal ) with regex!

    
asked by anonymous 02.09.2015 / 15:50

1 answer

1

Regex, definitely , is not the right tool to solve this problem.

If you want to compare two dates, then use the struct DateTime .

I'll assume that the input is two strings, s1 and s2 , in a valid format.

var d1 = DateTime.Parse(s1)
var d2 = DateTime.Parse(s2)

d1 < d2

If you are not sure that the string format is valid then you should use DateTime.TryParse

    
02.09.2015 / 15:55