Check whether date is in correct format or not

hI All,

I have to check whether date is in dd/mm/yyyy format or not. I am using below methods but still facing issue.

  1. StringDate = “10/10/1990”
  2. ConvDate = new DateTime()
  3. in IF loop

DateTime.TryParseExact(StringDate, “yyyy-MM-dd”, ultureInfo.InvariantCulture,DateTimeStyles.None, out ConvDate)

or

DateTime.TryParseExact(StringDate,“dd/MM/yyyy”,new CultureInfo(“en-US”),DateTimeStyles.None,out ConvDate)

Error is Comma or valid expression required.

Please help me.

Regards,
Shirish

Hi @Shirish

Use this regex, in Is Match activity

^([0-2][0-9]|(3)[0-1])(\/)(((0)[0-9])|((1)[0-2]))(\/)\d{4}$

If returned True means it matches with your date pattern. Try this

Main.xaml (5.4 KB)

Thanks,
Prankur

3 Likes

Thanks for your reply. I will try with ur soln, but if you provide any help on TryParseexact method then it will be good.

See this one

Date.TryParseExact(variable1,“dd/MM/yyyy”,CultureInfo.InvariantCulture,Globalization.DateTimeStyles.None,Nothing).ToString

Main.xaml (5.1 KB)

Thanks,
Prankur

1 Like

Many Thanks Prankur. It saves my efforts. Thanks again.

One thing, How we can check amount field from excel is numeric with nor more than 2 decimal places and in proper format i.e. should not contain any comma.

Thanks in Advance

Welcome, you can mark it as solution.

Try this for decimal thing with Is Match activity

^[0-9]*\.[0-9][0-9]$

Thanks,
Prankur