Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
sk88024
Creator
Creator

Difference between two Dates excluding weekends

Hi Everyone,

Need your help on this issue - 

So, I've two date fields as shown below and I want to get the time difference between these two dates. The difference should exclude Saturday and Sunday. 

I saw this post in Qlik forum and tried to refer to the same logic but somehow am getting -ve values for some of the records. Also, even the positive values are not correct.  

Solved: Networkdays Calculation - Exact Decimals Required - Qlik Community - 1275922

Time Diff.

=NetWorkDays(START_DATE, END_DATE) -2 + (1- frac(START_DATE)) + frac(END_DATE)

I can get the time diff. using END_DATE - START_DATE, but it does not exclude Saturday and Sunday. 

START_DATE END_DATE Network Days Time Diff.
19-10-2024 16:57:06 20-10-2024 06:54:52 0 -1.42
31-08-2024 16:27:58 01-09-2024 08:27:50 0 -1.33
27-04-2024 04:29:00 27-04-2024 04:29:00 0 -1.00
22-01-2025 12:38:02 24-01-2025 05:33:39 3 1.71
24-02-2025 18:29:04 26-02-2025 11:43:29 3 1.72
16-01-2025 13:46:51 20-01-2025 07:01:32 3 1.72
02-01-2024 13:31:30 25-01-2024 02:06:07 18 16.52

 

Thank you

Labels (2)
1 Solution

Accepted Solutions
sk88024
Creator
Creator
Author

Thank you for your effort. 

I found the exact solution after some trial and error.

NetworkDays(START_DATE, END_DATE) + Frac(Timestamp(END_DATE) - Timestamp(START_DATE)) 

View solution in original post

2 Replies
JandreKillianRIC
Partner Ambassador
Partner Ambassador

Hi @sk88024 

Something like this? 

JandreKillianRIC_0-1740663627058.png

So the top one is actually 17 days and 12 hours. 

IF(NetWorkDays(Floor(START_DATE), Floor(END_DATE)) >= 1, 
Interval(Interval(Frac(END_DATE)-Frac(START_DATE), 'hh:mm:ss') +
NetWorkDays(Floor(START_DATE), Floor(END_DATE)), 'DD hh:mm:ss'), 0)

Let me know! 

Regards Jandre

Mark the solution as accepted that solved your problem and if you found it useful, press the like button! Check out my YouTube Channel | Follow me on LinkedIn

sk88024
Creator
Creator
Author

Thank you for your effort. 

I found the exact solution after some trial and error.

NetworkDays(START_DATE, END_DATE) + Frac(Timestamp(END_DATE) - Timestamp(START_DATE))