How to know if a date is valid?

Hello friends, I want to know if a String is a valid date, and see the result in a MessageBox. The date is in the format “dd/mm/yyyy”.

For example, if the string is “01/01/2018”, it returns “It is valid”

If the string is “30/02/2018”, it returns “Not valid”, because February does not have 30 days.

If the string is “14/15/2018”, it returns “Not valid”, because there is no month 15.

Thanks friends!!

if (DateTime.TryParseExact(str, “dd/MM/yyyy”, null, DateTimeStyles.None, out dt) == true)

Try this and tell me if it works for you :slight_smile:

1 Like

Hello Niket_Ghai, sorry, it doesn’t work :frowning:.

This is my capture of screen.

date

1 Like

If you are using a flow decision you need not use ==True! Try removing ==True

I just remove it. I can see this:

The message is something like this:

A comma, or “)”, or the continuation of a valid expression was expected.

Yes! Gives the same error! I will look into this and get back to you soon :slight_smile:

Thank you!! I appreciate it a lot!! :slight_smile:

I have found a solution, which works for MM/dd/yyyy format! Will that work for you?

Yes, no problem. I work with that format, and then I change it to the format I need. No problem :slight_smile:

Main.xaml (11.1 KB)

Here is the workflow :slight_smile:

Cheers!!

1 Like

Thank you so much Niket_Ghai :smiley:

1 Like