--- title: "DAYSDIFF(A,B)" slug: "engineeringdatefunction2-10" updated: 2021-10-14T16:39:01Z published: 2021-10-14T16:39:01Z canonical: "docs.datajet.app/engineeringdatefunction2-10" --- > ## 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. # DAYSDIFF(A,B) ## Date Transform: DAYSDIFF(A,B) ## Returns the number of days difference between two dates, where A is taken away from B DAYSDIFF(A,B) = B - A ## Purpose Use this function to calculate: - The number of days between two dates - The elapsed time in days between two time-stamps - The amount of time between an event and a specific date ## Return Value | Property | Value | | --- | --- | | **FieldType** | Integer | | **FieldSize** | Med | | **DataType** | Discrete | | **DataSize** | Short | ```shell Example Return Value: -N to N where N is the maximum difference between dates for any individual record N is an integer ``` ![](https://cdn.document360.io/73b6469b-c1e4-47e9-aa65-986c8ebd17ca/Images/Documentation/DAYSDIFF_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”: “DAYSDIFF(A,B)” | DAYSDIFF(A,B) | | **A** | “p2”: “DateTimeFieldName” “p2”: “DateFieldName” “p2”: “#YYYY-MM-DD HH:MM:SS” “p2”: “#YYYY-MM-DD” | Required. Date to subtract from B. *Supports:* - **DataType:** Discrete / Continuous - **Field Type:** Date, DateTime - **Fixed Value:** #YYYY-MM-DD, e.g. #2021-04-05 - **Fixed Value:** #YYYY-MM-DD HH:MM:SS, e.g. #2021-04-05 11:01:08 | | **B** | “p3”: “DateTimeFieldName” “p3”: “DateFieldName” “p3”: “#YYYY-MM-DD HH:MM:SS” “p3”: “#YYYY-MM-DD” | Required. Comparator Date. *Supports:* - **DataType:** Discrete / Continuous - **Field Type:** Date, DateTime - **Fixed Value:** #YYYY-MM-DD, e.g. #2021-04-05 - **Fixed Value:** #YYYY-MM-DD HH:MM:SS, e.g. #2021-04-05 11:01:08 | ## JSON Sample ![](https://cdn.document360.io/73b6469b-c1e4-47e9-aa65-986c8ebd17ca/Images/Documentation/DAYSDIFF_JSON.PNG) ## Usage Notes The order in which fields A and B are specified will affect the value of DAYSDIFF(A,B) See also [ABSDAYSDIFF(A,B)](/v1/docs/engineeringdatefunction2) ## Example | Example | Details | | --- | --- | | **Description** | Calculate the number of days between Purchase and Shipping | | **Input** | - Table: = [transactions] - Function: = DateTransform - **DateTimeFunction: = DAYSDIFF(A,B)** - A:= [transactions].[dtShipping] - B: = [transactions].[dtPurchase] - Name: =DaysDiff | | **Sample** | ![](https://cdn.document360.io/73b6469b-c1e4-47e9-aa65-986c8ebd17ca/Images/Documentation/DAYSDIFF_Example.PNG) |