Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
mueen_khan_mm
New Contributor

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
Esteemed Contributor

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

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


7 Replies
MVP
MVP

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

OmarBenSalem
Esteemed Contributor

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

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


MVP
MVP

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

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

OmarBenSalem
Esteemed Contributor

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

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

MVP
MVP

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

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

mueen_khan_mm
New Contributor

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

Hi Sunny,

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

mueen_khan_mm
New Contributor

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

Hi Omar,

THis one really worked.

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

Thanks for all ur support and time

Community Browser