Announcements
Sept. 27, 10AM ET Do more with Qlik, Insight Advisor – our intelligent AI-assistant in Qlik Sense: Register
cancel
Showing results for
Did you mean:
Anonymous
Not applicable

Is there any function which gives me number of days in provided month

Hi All,

Is there any function which gives me the number of days in a month and takes month as input parameter.

Ex: NumberOfDays(JAN)  = 31 DAYS

NumberOfDays(APR)   = 30 DAYS

1 Solution

Accepted Solutions
MVP

I think you can use day() function on monthend() to calculate this, e.g. if MONTHFIELD is the input month (and it is a numeric month value or a dual, just like month(DATE) would return), try

=Day(MonthEnd(Makedate(Year(Today()),MONTHFIELD)))

this calculates the number of day of a month for this year (to state a year is relevant for leap years / February day numbers).

3 Replies
Partner - Creator III

Hi,

Never did it, but maybe AddMonths() function can help as follows - NoOfDaysInMonth = AddMonths(FirstDateOfMonth, 1) - FirstDateOfMonth.

Not sure if syntax is ok but this is what the first thing that comes to mind.

Best regards,

Maxim

MVP

I think you can use day() function on monthend() to calculate this, e.g. if MONTHFIELD is the input month (and it is a numeric month value or a dual, just like month(DATE) would return), try

=Day(MonthEnd(Makedate(Year(Today()),MONTHFIELD)))

this calculates the number of day of a month for this year (to state a year is relevant for leap years / February day numbers).

Partner - Creator III

Great!

MonthEnd() and MonthStart() make it even more logical, I've just tried the following:

=Floor(MonthEnd(Today()))-Floor(MonthStart(Today()))+1

It works, just replace Today() with the date you need.

Best regards,

Maxim

Community Browser