Hi team, is there a way to calculate the business hours (lets say 9am - 5pm) between two dates?
For example if I have two log messages which contain date fields as:
- 2020-08-03T09:00:00Z (Monday)
- 2020-08-05T09:00:00Z (Wednesday)
I could use the following to get diff in milliseconds:
| toMillis(parseDate(date1, "yyyy-MM-dd'T'HH:mm:ss'Z'")) as date1_milliseconds
| toMillis(parseDate(date2, "yyyy-MM-dd'T'HH:mm:ss'Z'")) as date2_milliseconds
| abs(date1_milliseconds - date2_milliseconds) as diff_milli
This would give me the equivalent of 48 hours in milliseconds but what I would like is to only get 16 hours (two days with 8 hour working days), ignoring the remaining 32 hours.
Is there a way to determine only business hours between two dates?
Please sign in to leave a comment.