HOURSDIFF(A,B)
  • 1 Minute to read
  • Dark
    Light
  • PDF

HOURSDIFF(A,B)

  • Dark
    Light
  • PDF

Article summary

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

PropertyValue
FieldTypeInteger
FieldSizeMed / High 
DataTypeDiscrete 
DataSizeInteger


Example Return Value: -N....N  where N = maximum difference in hours between A and B

Parameters

ParameterJSONDescription
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:  
  • DataType: Discrete / Continuous
  • Field Type: DateTime
  • Fixed Value:  #YYYY-MM-DD HH:MM:SS,    e.g. #2021-04-05 11:01:08
B“p3”: “DateTimeFieldName”
“p3”: “#YYYY-MM-DD HH:MM:SS”
Required.  DateTime B
Supports:  
  • DataType: Discrete / Continuous
  • Field Type: DateTime
  • Fixed Value:  #YYYY-MM-DD HH:MM:SS,    e.g. #2021-04-05 11:01:08

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:00
  • A=#2020-01-02 00:00:00,  B = #2019-01-02 00:00:00
  • A=FieldA, B=FieldB
  • A=#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

ExampleDetails
DescriptionCalculate number of hours between purchase and shipping
Input
  • Table: = [transactions]
  • Function: = DateTimeTransform
  • DateTimeFunction: = 
  • A:= [transactions].[dtPurchase]
  • B: = [transactions].[dtShipping] 
  • Name: =ShippingTime_Hour
Sample



Was this article helpful?

What's Next