HOURSBEFOREMAX(A)
  • 1 Minute to read
  • Dark
    Light
  • PDF

HOURSBEFOREMAX(A)

  • Dark
    Light
  • PDF

Article summary

DateTime Transform: HOURSBEFOREMAX(A)

Returns the number of hours before the maximum value of DateTime A

HOURSBEFOREMAX(A) =  HoursDiff(Max(A),A)

where

  • Max(A) = Maximum value in Field A
  • A = Value of current record
  • HoursDiff(Max(A),A) = total number of hours between Max(A) and A


Purpose

Use this function to:
  • Calculate hourly difference between an individual transaction and the most recent transaction
  • Calculate the age, in hours, of an event

Return Value

PropertyValue
FieldTypeInteger
FieldSizeMed / High
DataTypeDiscrete / Continuous
DataSizeInteger


Example Return Value: -N....N  where N = maximum difference in hours between records in Field A

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”: “HOURSBEFOREMAX(A)”HOURSBEFOREMAX(A)
A“p2”: “DateTimeFieldName”
“p2”: “#YYYY-MM-DD HH:MM:SS”
Required.   The DateTime field from which to extract the Max Hour and the Hour to compare it with.   Must be on the target table.
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

See also:

  • HOURSDIFF(A,B)   (DateTime)
  • Engineering | Expression Field

Example

ExampleDetails
DescriptionCalculate number of hours between current row and maximum DateTime for the field
Input
  • Table: = [transactions]
  • Function: = DateTimeTransform
  • DateTimeFunction: =HOURSBEFOREMAX(A)
  • A:= [transactions].[DateTime]
  • Name: =HoursBeforeMax
Sample



Was this article helpful?

What's Next