How to check if a value is a date

I get a date from excel and store it into a string. Once in a string, I convert it into a DateTime object. But I want to set up an if condition to check if the value is a date then convert it. Not sure how to check if the value is a date.

Can anyone help?

1 Like

You can use Try Parse .

More details are here -

Regards,
Karthik Byggari

4 Likes

Have created a workflow based on your requirement.

Please mark as this solution if it is resolved.
DateFormat.zip (24.2 KB)

1 Like

If suppose your DateTime value is stored in a str_datetime which is format “dd/MM/yyyy hh:mm:ss” then use this expression in a IF condition

Date.TryParseExact(str_datetime.ToString.SubString(0,10),“dd/MM/yyyy”,Nothing,Globalization.DateTimeStyles.None,Nothing)

Cheers @bobby

5 Likes

I got it working. Thanks @Palaniyappan. Also, thanks for taking the time to answer my question. @Mohansadaiyapillai and @KarthikByggari. Great suggestions as well.

Thanks guys. :slight_smile:

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.