Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Deepak87
Partner - Contributor III
Partner - Contributor III

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 - Specialist III
Partner - Specialist III

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 - Contributor III
Partner - Contributor III
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