How about skipping the calculations altogether and just use:
formatDateTime([%EndOfCurrentMonth%], 'd')
If you want the integer, wrap it in a parseInteger function.
Using this expression, can get the current month’s total number of days:
ceil(daysBetween([%BeginOfCurrentMonth%],[%EndOfCurrentMonth%]))
This is a very simple logic. It is always same for all months for any Year except for February in Leap Years.
So assuming you have Month and Year as input to a microflow, there,
if the month is
Jan then 31 days
Feb is 29 days is Leap Year else 28 days,
March is 31,
April is 30
May is 31
June is 30
July is 31
August is 31
September 30
October 31
November 30
December 31
Using the daysBetween() function along with other date functions this can be achieved.
An example of how you could do this.
daysBetween(trimToMonths([%CurrentDateTime%]),addDays(trimToDays(addDays([%EndOfCurrentMonth%],1)),-1))
You could then vary the [%CurrentDateTime%] and [%EndOfCurrentMonth%] and make them custome parameters that you pass into a microflow.
daysBetween(trimToMonths($DateParameterOne),addDays(trimToDays(addDays($DateParameterTwo,1)),-1))
Alternatively you could use the dateTime functions with the daysBetween function:
daysBetween(dateTime(2007, 2, 13, 1, 1, 1), dateTime(2007,1,1,1,1,1))