Qlik Community

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
QlikWorld 2022, LIVE in Denver CO., May 16-19, 2022. REGISTER NOW TO RECEIVE EARLY BIRD PRICING
cancel
Showing results for 
Search instead for 
Did you mean: 
Deepak87
Partner
Partner

Date Time difference in hours excluding the weekends

Hi All,

I need to calculate the Date & time difference in hours excluding the weekends. i have a below expression, which provides time difference in hours. But i need to exclude the weekends as well in this.

interval(timestamp2 - timestamp1,'hh')

 

looking for any suggestion.

Labels (1)
2 Replies
fosuzuki
Partner
Partner

Hi,

considering 2 variables:

v1 = 2020-08-21 20:00:00 (older timestamp)

v2 = 2020-08-24 21:00:00 (newer timestamp)

This expression will use the NetWorkDays function to get the working days (excluding weekends), and the second part will calculate the difference on the time part:

=interval((NetWorkDays('$(v1)', '$(v2)') - 1) + (frac('$(v2)') - frac('$(v1)')),'hh')

Deepak87
Partner
Partner
Author

Hi Fosuzuki,

I think your solution works when v2 is greater than v1 variable. But in my case, some times, v1 is greater than v2.

Regards,

Deepak K M