Compare date value with specific Format

Hi ,

I want to check given date is in correct format or not.
i.e date should be in YYYY-MM-DD format.

someone please help me to resolve this.
Thank you in advance.



DateTime.TryParseExact(dateAsString, “yyyy-MM-dd”, Nothing, Nothing , resultAsDate) will return a boolean and the potentially converted dateTime. True if format matches → False if not.
Note that the method takes iFormatProvider and DateTimeStyles as arguments which I just gave ‘Nothing’ in this test.
You can research more:


1 Like

Thank you for the response.

I also got one method DateTime.TryParse(“2018-12-31”,InputDate).ToString
2018-12-31 → format in which you expect the date
InputDate → input date

@surajhy Check attached file

Main.xaml (6.1 KB)

Yes but TryParse will accept any format, e.g. “31.12.2018”. According to your initial requirements this should not be accepted.

TryParse(inputString, outputDate)

Hii @Topi
what is result as date ?
and that variable contains

It is a DateTime (variable type) equivalent of the given date string if the conversion was successful.

variable that
stores result?