I am trying to calculate the number of hours worked between a start time and end time by using DateTimeDiff.
The problem arises when there are weekends in between.
Eg: Start = 7/7/2023 23:00:00 (Friday) - End = 7/10/2023 6:00:00 (Monday)
Now when I use DateTimeDiff the difference in hours turns out to be 55 Hours. Where as I want to disregard the hours from the weekend.
FYI, This cannot be achieved by simply reducing 48 Hours incase of weekends in between the Start and End values because if the End value was 7/8/2023 1:00:00 in the above example. The final result would be a negative value which is not true.
Thank you in advance :)
Hi @siiddd , please see if the workflow works for you.
I have split up the calculations by parts to account for 2 portions before summing them up
1. Number of hours left in the Start Date, Number of hours passed in the End Date [0 if it falls during the weekend]
2. Number of full days between dates (excluding Start and End date) * 24 [excluding weekends]
Hope this helps.
Hi @siiddd
Try reading it here: https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Datetimediff-using-only-weekda...
In addition, since you do not want to count weekends...
Do you want to count Public Holidays as well? What about Working Hours? How detailed must it be?
I'm sure you'd like to account for Public Holidays as well right. Otherwise, @suwenchuan's workflow is pretty good.