Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
PrashantRupani
Creator
Creator

Subtract between two dates

Using Qlik Sense

I have a requirement in which I need to subtract two dates and they should exclude weekends too and then convert that in hours.

So I found something on qlik forums on using this formula to calculate two dates and exclude weekend :

=Num(NetWorkDays(Date1, Date(Date2)) -2 + (1-frac(Date1_TS)) + frac(Date2_TS),'#,##0.00')

 Note: Date1_TS and Date2_TS is respective timestamps part of Date1 and Date 2. 

So for example if Date 1 : 2020-11-30 10:53:49 & Date 2 is 2020-12-04 07:05:12 then I get the result Days as 3.86.

If I convert that in hours, I simply multiplied by 24 I get the result in QS is 92.61. See this f

=Num(NetWorkDays(Date1, Date(Date2)) -2 + (1-frac(Date1_TS)) + frac(Date2_TS),'#,##0.00')*24

Actually when you multiple using a calculator the result is 92.64. I am unable to understand why this difference. 

Can someone help with this?

Thanks

 

Labels (2)
0 Replies