DateTime Transform: HOURSDIFF(A,B)
Returns difference in hours between DateTime A and DateTime B
HOURSDIFF(A,B) - AbsoluteHours(B) - AbsoluteHours(A)
Where
- AbsoluteHours(B) = number of hours from date reference to B
- AbsoluteHours(A) = number of hours from date reference to A
- date reference = Jan 0, 0000 00:00:00
Purpose
Use this function to:
- Calculate the age of events
- Calculate the number of hours between events
Return Value
| Property | Value |
|---|---|
| FieldType | Integer |
| FieldSize | Med / High |
| DataType | Discrete |
| DataSize | Integer |
Example Return Value: -N....N where N = maximum difference in hours between A and B
Parameters
| Parameter | JSON | Description |
|---|---|---|
| Table | “targetTable”: “MyTableName” | The target table on which the new field will be created |
| Filter | “dataset”: {DataSet_JSON} | Optional. If a filter is applied, records not in the filter Recordset will be returned as null. |
| DateTime Function | “p1”: “HOURSDIFF(A,B)” | HOURSDIFF(A,B) |
| A | “p2”: “DateTimeFieldName” “p2”: “#YYYY-MM-DD HH:MM:SS” | Required. DateTime A Supports:
|
| B | “p3”: “DateTimeFieldName” “p3”: “#YYYY-MM-DD HH:MM:SS” | Required. DateTime B Supports:
|
JSON Sample

Usage Notes
Any combination of Field/Immediate value is valid for A and B
e.g.,
A=FieldA,B=#2019-01-02 00:00:00A=#2020-01-02 00:00:00, B = #2019-01-02 00:00:00A=FieldA, B=FieldBA=#2020-01-02 00:00:00, B=FieldB
HOURSDIFF can be manually calculated using DAYSDIFF, (A-B), (A*B), HOUR, (A+B+C) :


See Also;
- MINSDIFF(A,B) (DateTime)
- SECSDIFF(A,B) (DateTime)
- Engineering | Expression Field
Example
| Example | Details |
|---|---|
| Description | Calculate number of hours between purchase and shipping |
| Input |
|
| Sample |