Comparing dates based off of the month

I have a date in a string “2022-02-16” format yyyy-MM-dd i just want to do a comparison with the day and month but not the year. I want to check to see if the date is before or after today’s date just based off or the day and month.

For example “2022-02-16” would be considered a past date based off of the day and month and “2022-04-16” would be considered a future date based off of the day and month if we were comparing it to today. is there a way to do this without taking the year into consideration?


You can try like this

DateTime.ParseExact(Now.Year.ToString + "-" + "2022-02-16".Split({"-"},2,StringSplitOptions.None)(1),"yyyy-MM-dd",System.Globalization.CultureInfo.InvariantCulture) > Now

In this 2022-02-16 can be replaced with any date and it gives true or false depending on date being greater or less than today


Hi @duaine.b

another approach could be the following:
booResult will return True if the date is past, and False if the date is future

Assign dateToUse (DateTime Type)

DateTime.ParseExact(strInput,"yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture)

Assign booResult(Boolean Type)

If(dateToUse.Month < Now.Month OrElse (dateToUse.Month = Now.Month AndAlso dateToUse.Day < Now.Day), True, False)


Hi @duaine.b

Give a try to this method

Sample Workflow
DateCompare.xaml (10.6 KB)

Hi @duaine.b ,

As you would need to neglect the year comparison, you could substitute the Current Year in the Input String itself and then Perform the Comparison with Current Date. As the input string is in the form yyyy-MM-dd, CDate() should directly convert it to the DateTime format.

Check the below Steps :


Visuals :

1 Like

how would it work if the format changes to “27-Apr-2022”


If the format changes then the formula needs to change accordingly

DateTime.ParseExact("22-Apr-2022".Substring(0,7) + Now.Year.ToString,“dd-MMM-yyyy”,System.Globalization.CultureInfo.InvariantCulture) > Now


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