Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Hi is there a way to find diffrence between 2 dates excluding weekend.

Hi i have 2 dates , start_date and end_date for the month of November , i am trying to find the difference between these 2 dates excluding weekends ( ie Saturday and Sunday).

If u can provide example it will be great, i am using qliksense

1 Solution

Accepted Solutions
OmarBenSalem

Can u try :

end_date -start_date -( 2*(round((end_date -start_date )/7)))

example:

date('29/01/2018')-date('02/01/2018')-(   2*(round((date('29/01/2018')-date('02/01/2018'))/7)))

=> 19 days


or


date('29/01/2018')-date('02/01/2018')-(   2*(round((date('29/01/2018')-date('02/01/2018'))/7))) +1

=> 20 days


View solution in original post

7 Replies
sunny_talwar

OmarBenSalem

Can u try :

end_date -start_date -( 2*(round((end_date -start_date )/7)))

example:

date('29/01/2018')-date('02/01/2018')-(   2*(round((date('29/01/2018')-date('02/01/2018'))/7)))

=> 19 days


or


date('29/01/2018')-date('02/01/2018')-(   2*(round((date('29/01/2018')-date('02/01/2018'))/7))) +1

=> 20 days


sunny_talwar

But why this Omar, did I missing something from the initial post? Why can't we use NetWorkDays() here?

OmarBenSalem

NetworkDays already eliminates the weekends? Didn't know that sorry !

sunny_talwar

It does, and I am amazed you have never used or heard about this function? Don't have to be sorry for anything, we are all learning new things... this is something new for you

Anonymous
Not applicable
Author

Hi Sunny,

thanks for your help and the link , it really helped in learning new syntax as well

Anonymous
Not applicable
Author

Hi Omar,

THis one really worked.

end_date -start_date -( 2*(round((end_date -start_date )/7)))

Thanks for all ur support and time