--- title: "DAYSBEFOREMAX(A)" slug: "engineeringdatefunction2-9" updated: 2021-10-14T15:11:38Z published: 2021-10-14T15:11:38Z canonical: "docs.datajet.app/engineeringdatefunction2-9" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.datajet.app/llms.txt > Use this file to discover all available pages before exploring further. # DAYSBEFOREMAX(A) ## Date Transform: DAYSBEFOREMAX(A) ## Returns the difference in days between A and Max(A) ## Purpose Use this function to calculate: - The number of days that elapsed between an event and the latest occurrence of that event - The number of days a transaction occurred before the latest transaction ## Return Value | Property | Value | | --- | --- | | **FieldType** | Integer | | **FieldSize** | Med | | **DataType** | Discrete | | **DataSize** | Short | ```shell Example Return Value: 0....N where N is the maximum number of days between the earliest and latest date in the dataset ``` ![](https://cdn.document360.io/73b6469b-c1e4-47e9-aa65-986c8ebd17ca/Images/Documentation/DAYSBEFOREMAX_Sample.PNG) ## 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. | | **DateTimeFunction** | “p1”: “DAYSBEFOREMAX(A)” | DAYSBEFOREMAX(A) | | **A** | “p2”: “DateFieldName” | Required. The date field from which to take the minimum value and the comparator values. *Supports:* - **DataType:** Discrete - **Field Type:** Date - **Fixed Value:** #YYYY-MM-DD, e.g. #2021-04-05 | ## JSON Sample ![](https://cdn.document360.io/73b6469b-c1e4-47e9-aa65-986c8ebd17ca/Images/Documentation/DAYSBEFOREMAX_JSON.PNG) ## Usage Notes See also [DAYSAFTERMIN(A)](/v1/docs/engineeringdatefunction2-8) ## Example | Example | Details | | --- | --- | | **Description** | Calculate age of a transaction in days | | **Input** | - Table: = [transactions] - Function: = DateTransform - **DateTimeFunction: = DAYSBEFOREMAX(A)** - A:= [transactions].[last_response] - Name: = DaysBeforeMax | | **Sample** | ![](https://cdn.document360.io/73b6469b-c1e4-47e9-aa65-986c8ebd17ca/Images/Documentation/DAYSBEFOREMAX_Example.PNG) |