Getting number of days in the given input month...

0
Hi all, This is Mahesh. Can anyone tell me the ways to get the number of days in the given input month. Thanks in advance
asked
1 answers
3

I don't know if it's the quickest way, but one way would be to:


formatDateTime(addDays(parseDateTime(‘01-<month+1>-<year>’, ‘dd-MM-yyyy’), -1), ‘dd’)

So basically what you do here is:

  • Take the first day of the next month (be sure to check which year the next month is in)
  • Subtract one day
  • Check the day number of that day. It is the last day of the month you wanted to check, and also equals the number of days in that month.

 

Edit:

It's early and I forgot daysBetween exists (thanks for reminding me, Mariusz). So get the first day of next month, the first day of the month you want to know, and use the daysBetween function.

answered