Here we will see how to get the days of a month in Power Automate. And also we will check whether this year is a leap year or not on a given date.

In Power Automate, select the Manually triggered flow, then click on the Next step

Next step we will provide a date, based on that date it will get the days of the month and also we will check that year is a leap year or not. Select Initialize variable action, then provide the variable name, type as string, and in value give a date.

Next, we will get the year from the given date, so click on the Next step, and select initialize variable action, the provide the variable name, type as integer, and in value write the below expression:

I use this formula:

int(formatDateTime(variables(‘Stratdate’),’yyyy’))

Now we will get the month from the given date, so click on the Next step and select initialize variable action, then provide the variable name, type as integer, and in value write the below expression:

I use this formula:

int(formatDateTime(variables(‘Stratdate’),’MM’))

Now we will check the given year in date is a leap year or not, so click on the Next step and select Compose action, then in input, write the below expression:

I use this formula:

or(and(equals(mod(variables(‘Year’), 4), 0), not(equals(mod(variables(‘Year’), 100), 0))), 
equals(mod(variables(‘Year’), 400), 0))
 
Now we will find the days in the given month, so click on the Next step, select Compose action, then in input write the below expression:
 
I use this formula:
 
if(equals(variables(‘Month’),2), if(outputs(‘IsLeapYr’), 29, 28), if(or(equals(variables(‘Month’),1), equals(variables(‘Month’),3), equals(variables(‘Month’),5), equals(variables(‘Month’),7), equals(variables(‘Month’),8), equals(variables(‘Month’),10), equals(variables(‘Month’),12)), ’31’, ’30’))

For any Help or Queries Contact us on info@crmonce.com or +918096556344