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

AGE(A,B)

  • Dark
    Light
  • PDF

Article summary

Date Transform: AGE(A,B)

Number of whole years between the dates represented by A and B

AGE(A,B) = B - A

Purpose

Use this function to:
  • Calculate the age of a customer at a specific point in time
  • Calculate the age of a transaction at a specific point in time
  • Calculate the number of whole years between two dates

Return Value

PropertyValue
FieldTypeInteger
FieldSizeLow / Med
DataTypeDiscrete
DataSizeShort


Example Return Value: -N....N  where N is maximum number of years between Value(A) and Value (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.
DateTimeFunction“p1”: “AGE(A,B)”AGE(A,B)
A“p2”: “DateField1Name”
“p2”: “#YYYY-MM-DD”
Required.
Supports: Date, DateTime, Fixed Value.
Fixed Value = #YYYY-MM-DD
e.g. #2021-04-05
B“p3”: “DateFieldOrValue2”
“p3”: “#YYYY-MM-DD”
Required.
Supports: Date, DateTime, Fixed Value.
Fixed Value = #YYYY-MM-DD
e.g. #2021-04-05

JSON Sample

Usage Notes

To calculate current age, use the AGE(A) function.    Use AGE(A,B) to calculate age in years between two fixed dates.

The number of years is calculated FROM B TO A.

Example


ExampleDetails
DescriptionCalculate transaction age on a specific day
Input
  • Table: = [transactions]
  • Function: = DateTransform
  • DateTimeFunction: = AGE(A,B)
  • A:= [transactions].[date]
  • B: = #2022-01-01
  • Name: =AgeIn2022
Sample

Was this article helpful?