Duration Calculations

Hi All,

The below expression aims to calculate the duration between the shift start time and shift end time in duration. It aims to handle cases where shift start is before midnight and shift end is after midnight. Both fields are in Time column type. And the column I am building this expression into is Duration column type, that is Shift Duration.

But it returns this error; Arithmetic expression ‘([Shift Start]+[Shift End])’ has inputs of an invalid type ‘Unknown’.

IF(
[Shift End]<[Shift Start],
("00:00:00 - "[Shift Start]) + [Shift End],
[Shift End]-[Shift Start]
)

Your expertise in helping me is appreciated.

Cheers,

Neşet

I believe adding time to time will give an error.

You may wish to take a look at how time math works in the associated post below. Also please take a look at the help article enclosed in that post and Time and Duration calculations.

The shift crosses over from one date to the next date in the example shared by you. This could possibly make using time type columns valid for calculating duration. However, generally, the DatetIme type column is more useful in such cases to calculate duration where days change.

[Adding time to time](https://community.appsheet.com/t/adding-time-to-time/49551/2) Questions

Based on the description, it sounds you could take a look at duration rather than time as result. Some peculiarities of time and duration columns to note [Time 1]- [Time 2] gives duration rather than time. “14:00:00”- “12:30:00” will result in duration of 01:30:00 If one tries addition [Time 1] +[Time 2] will give an error as two times cannot be added. “14:00:00”+ “12:30:00” will give an error for adding two times One can add [Time 1] + [Duration 1] which will give another time “1…

1 Like

Thank you very much Suvrutt. I will look into it.

2 Likes