Date Difference in Formulas
The Formula Editor supports calculating the difference between two date-time (timestamp) attributes. This is useful for measuring durations, such as the time between two events.
How to Use Date Difference
- Subtract one timestamp from another using the minus (-) operator.
- Both operands must be date-time attributes.
- The result type of the formula is a number, which represents the difference in days.
- The value can be fractional. For example:
- If the difference is 12 hours, the result is 0.5 days.
- If the difference is 36 hours, the result is 1.5 days.
Rules
- Only the minus operator (-) is allowed between two date-time attributes.
- Parentheses can be used to group multiple date differences.
- You can add or subtract multiple date differences, but each pair must be grouped with parentheses.
- If you try to use any operator other than minus (-) between two date-time attributes, or if you do not group pairs with parentheses when using more than two date-time attributes, the Formula Editor shows an error.
Example Formula Configurations
| Use Case | Example Formula | Result Type |
|---|---|---|
| Process cost | CycleTime * HourlyRate | Number |
| Date difference | Timestamp2 - Timestamp1 | Number |
| Cycle time difference | TotalCycleTime - ReqCycleTime | Cycle Time |
| Custom ratio | (EventCount(A) + EventCount (B)) /(EventCount (C) + EventCount (D)) | Ratio |
| Approval rate | CaseCount(Approved) / CaseCount(Total) | Ratio |