If else condition to check date format

Hi Guys,

I am having two different format of dates i.e. 20170802 and another is 14-06-2019
in this format. i want to check if dates comes withy the format yyyyMMdd then change its format to dd-MM-yyyy. Please let me know the what should i write in IF condition to check the date format.

Thanks & Regards
Gaurav Kumar

In IF condition you can check “-” in 3rd place of string. if condition is true go for 2nd format otherwise first.

Hello Gaurav,

You can use something like this :

If (your date string).contains("-") then your logic

2 Likes

IF DateVariable.contains("-")
Then - Blank
else - DateVariable= DateVariable.substring(6,2)+"-"+DateVariable.substring(4,2)+"-"+DateVariable.substring(0,4)

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