Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Thabang231
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
BrunPierre
Master
Master

The NetWorkDays function is worth checking out.

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

Thabang231
Contributor III
Contributor III
Author

@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.

vinieme12
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

vinieme12_0-1670399106647.png

 

 

 

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

Hi,

Try this expression - 

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

Regards,

SK