Compare 2 different months and find which month comes first in the year

Hi All,

I have a requirement to compare the two different months of the year and find the first month of the year.

Thanks,
Kamalnath S
Senior Automation Engineer

solution will depend on the datatype of the months are given as input. Can you share with us?

The Datatype was DateTime

When both dates are of DateTime we can do:
grafik

Hi @Kamalnath

Try this:

Assign -> date1 = CDate("01/15/2024")

Assign -> date2 = CDate("03/10/2024")

Assign-> firstMonthOfYear = If(date1.Month = date2.Month, date1.Month, If(date1.Month < date2.Month, date1.Month, date2.Month))

date1, date2 are of DataType System.DateTime. firstMonthOfYear is of DataType System.Int32.

The above dates are just examples.

Hope it helps!!