Duration expression – time between two dates¶
The duration expression calculates how much time lies between two dates – as a number in a chosen
unit (for example 1.5 hours) or as readable text such as "2 hours, 30 minutes". Optionally it only
counts the working time of a business hours calendar.
1. At a glance¶
| Purpose | Calculates the time from a start to an end date |
| Typical use | Age of a ticket, processing time in working hours, "due in 3 days" texts, comparing two dates |
| Returns | A decimal number in the chosen unit, or text with "Return Time Remaining" |
| Related | Date Time Math, Business hours |
2. Settings¶
| Setting | Meaning | Default |
|---|---|---|
| "Start" | The start date | – (required) |
| "End" | The end date, for example the system function ServerDateTimeUtc for "until now" |
– (required) |
| "Return Time Remaining" | Returns readable text instead of a number | off |
| "Unit" | Only without "Return Time Remaining": the unit of the result – Milliseconds, Seconds, Minutes, Hours, Days, Weeks, Months or Years. The arrow of the setting offers them under "Units". |
– (required) |
| "Smallest Unit" | Only with "Return Time Remaining": the smallest unit shown in the text | Millisecond |
| "Largest Unit" | Only with "Return Time Remaining": the largest unit shown in the text | Week |
| "Use Business Hours" | Counts only working time | off |
| "Use Business Hours By Expression" | The calendar is determined by an expression | off |
| "Business Hours" | The business hours calendar | – |
| "Business Hours Expression" | An expression that returns the id or the name of the calendar | – |
3. Behaviour¶
- The result is End minus Start. It is negative when the end lies before the start.
- The number has decimals: 90 minutes in the unit
Hoursgive1.5. Monthscounts 30 days,Years365 days,Weeks7 days.- The unit must be written in the plural (
Hours, notHour); upper and lower case do not matter. Any other text makes the result empty. - With "Return Time Remaining", the duration is written as text in the language of the user, for
example "2 hours, 30 minutes". "Smallest Unit" and "Largest Unit" accept singular or plural
(
Minute,Minutes, …). - With business hours, only the working time between start and end counts. If no calendar can be determined, the plain calendar duration is returned.
An empty start or end counts as 1 January 1753. A duration from an empty field to today is then more than 270 years. Check with a condition that both dates are filled in, wherever a field can be empty.
4. Examples¶
Age of a ticket in days: Start = field "Created on", End = system function ServerDateTimeUtc,
Unit = Days.
Processing time in working hours: Start = "Received on", End = "Resolved on", Unit = Hours,
"Use Business Hours" on, "Business Hours" = "Service desk".
Remaining time as text: Start = ServerDateTimeUtc, End = field "Due on",
"Return Time Remaining" on, Smallest Unit = Minute, Largest Unit = Day – for example
"2 days, 4 hours, 15 minutes".
Comparing two dates: "Is the end after the start?" – Duration with Start = "Start date",
End = "End date", Unit = Minutes, then a logical expression "Duration
GreaterThan 0".