@silvia93
we can handle as following:
see defined 2 test strings and a string array with the 2 different dateformats below:
Parsing we can do within an assign like this:
DateTime.ParseExact(strDate1,Formats,CultureInfo.InvariantCulture,DateTimeStyles.None)
DateTime.ParseExact(strDate2,Formats,CultureInfo.InvariantCulture,DateTimeStyles.None)
And will receive following
the yellow lines are the statement that can be used within the condition block of an if
Kindly note:
- As we used the dateformats within a string array we have to define the last forth parameter as well from the method signature. But with this we can use the same call for both formats (sure different datestrings are to pass)
- an alternate for a single format parse would be like
DateTime.ParseExact(strDate1,"dd.MM.yyyy",CultureInfo.InvariantCulture)
- ensure that system.Globalization is imported:
Let us know your feedback