I have tried to use datediff however it only gives the hour difference between two dates. I would like to receive only the hours that are during the working days and working hours. Example provided below:
Start Date: 19/08/2022 09:42:13
End Date: 22/08/2022 09:54:22
Outcome I receive from Datediff("HH", [Start Date], [End Date]) = 72.20
The actual outcome I would like would be approx. = 8.13
OK so you mean something like NetWorkHours rather than days. (I don't understand your comment about medians.)
Assuming you have a data table with a column for the start date and a column for the end date (and these are of DateTime data type) you could create a TERR expression that takes the two dates as input and produces a number of worked hours as output.
I have used this answer as a start: How to calculate networkdays minus holidays between 2 dates
but that does not cover hours. So here is my suggested solution. The idea is to initially remove the start and end day (which are incomplete days) and calculate the number of whole days minus weekends as in the previous solution. Then simply multiply it by the working hours in a day. Then take the first and last day and calculate the hours worked. Then add the two together.
Create a TERR expression function (from menu Data > Data Function Properties > Expression Function)
call the TERR expression function e.g. TERR_netWorkingHours. This will give you the total hours worked.
Use it by creating a calculated column as:
TERR_netWorkingHours([startDate],[endDate])
where [startDate] and [endDate] are your original columns.