Skip to main content
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
Showing results for 
Search instead for 
Did you mean: 
Contributor III
Contributor III

Count number of days from different months

Hi Team I am looking for a solution, I currently want to do count from 2 date fields with different months,

here is the formula I'm using,

 count(" To Date" - " From Date")

I am getting the correct count when the "To date" are on same month from "From date", but when months are different for instance count('2022-09-02' - '2022-08-31') should give us 3, not 2.

please assist. thanks in advance!

Labels (1)
4 Replies
Partner - Master
Partner - Master

The NetWorkDays function is worth checking out.

NetWorkDays ("To Date", " From Date") as [Days Taken during the week]

Contributor III
Contributor III

@BrunPierre  the networtkDays function i have used to get the during, and it works correct, now the issue is the total days taken including weekends on the different months, please look at my attachment.

Hope you can assist there.

Champion III
Champion III

simply subtracting the two dates will return difference in days and adding +1  is sufficient as dates are just numbers

" To Date" - " From Date" + 1   as DateDiff


Also COUNT() as you are using will always return 1 and is incorrect, 

Your count() might actually be returning the no of rows for that record and not the difference in days





Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Contributor III
Contributor III


Try this expression - 

count(floor(Date#("To Date") - Date#("From Date"))) + 1