Validate date from a string

Hi Team,

I want to validate if a given string contains correct date.


If you look at the above image, it shows date mistakenly entered as october 32, 2018

Bot must throw this as an invalid date

I know there is datetime.parse method for validating date

but my confustion is actually there is no restriction put on how the customer need to give date

i.e it could be 10/32/2018 - MM/dd/2018 or 32.10.2018

Could anyone please help on this?


Use assign datetime1 = Convert.todatetime(String1.replace(".","")) inside try.

So that it will convert all the given format. And if date is not valid, it won’t convert.

Need help to validate if the excel column contains correct date format.

Validate format is MM/DD/YYYY or MM-DD-YYYY

Could you help me with the expression ?

you want to validate if your date is in correct format or not??

@Pradeep_Shiv Yes

@Boopathi What did you mean there is no restriction in how the Customer will input the date? Can it be Oct 28, 2019 ?

well you can do this get your Column values like this
row(“yourDateColumnName”).ToString and pass this is IsMatches Activity and use this pattern
\d{1,2}(/|-)\d{1,2}(/|-)\d{4} and this will return you boolean value and you can play further!
Cheers @veerishu

1 Like

@supermanPunch As of now, we can consider only MM/DD/YYYY as the valid input. Could anyone help me with the expression?

if that is the only expression for now ??

@Pradeep_Shiv: I am taking some assignments on my own and setting the rules for it. No hard and fast rule.

I am just exploring different ways


all right @veerishu the above expression will help you!

1 Like


I have done it in the following way but is says invalid for all the date format.


1 Like

@Pradeep_Shiv This worked, Thanks :v:

1 Like