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

difference between 2 timestamps without weekends, except when enddate is in a weekend

Hello,

 

The goal is to calculate the difference between two timestamp without weekends. The problem; when the enddate is in a weekend, the formula still substracts the full 2 days, instead of calculating the real duration from friday 00:00 till the endtime, and substracting the duration with that time.

 

See below; the leftmost column is the correct duration, the column next to that one is what I get. 

Quentinn_0-1642339519323.png

 

A solution would be hugely appreciated!

1 Solution

Accepted Solutions
Quentinn
Contributor III
Contributor III
Author

I'm almost there!

Now i'm exactly one day short so it has to do with the round in my opinion, any ideas?

 

Quentinn_0-1642346616491.png

 

View solution in original post

4 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think when you reference enddate in your expression, you could round off the time if it's a weekend date. Something like:

if(WeekDay(FirstValidatingDateTime) > 4, Floor(FirstValidatingDateTime), FirstValidatingDateTime)

-Rob

Quentinn
Contributor III
Contributor III
Author

Many thanks, i'm on the right path now

 

However, it refuses to round off sundays, even if i specify the beginning weekday

 

Quentinn_0-1642345731856.png

 

Quentinn
Contributor III
Contributor III
Author

i managed to solve that, weekday 0 is sunday and 6 is saturday for some reason, i'll see if i can make my calculations work with your input

Quentinn
Contributor III
Contributor III
Author

I'm almost there!

Now i'm exactly one day short so it has to do with the round in my opinion, any ideas?

 

Quentinn_0-1642346616491.png