Boopathi
(Boopathi Manogar)
October 28, 2018, 1:13pm
1
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?
Thanks,
Ulaga
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.
veerishu
(Veeresh Uppin)
February 10, 2020, 6:56am
3
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??
@veerishu
@Boopathi What did you mean there is no restriction in how the Customer will input the date? Can it be Oct 28, 2019 ?
@veerishu
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
veerishu
(Veeresh Uppin)
February 10, 2020, 7:28am
8
@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 ??
veerishu
(Veeresh Uppin)
February 10, 2020, 7:34am
10
@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
2 Likes
all right @veerishu the above expression will help you!
1 Like
veerishu
(Veeresh Uppin)
February 10, 2020, 8:13am
12
@Pradeep_Shiv
I have done it in the following way but is says invalid for all the date format.
veerishu
(Veeresh Uppin)
February 10, 2020, 9:23am
14
@Pradeep_Shiv This worked, Thanks
1 Like