Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead 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
swuehl
MVP
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).

View solution in original post

3 Replies
maksim_senin
Partner - Creator III
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

swuehl
MVP
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).

maksim_senin
Partner - Creator III
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