--- title: "SECSDIFF(A,B)" slug: "datetimetransform-template-8" updated: 2021-11-16T12:44:21Z published: 2021-11-16T12:44:21Z canonical: "docs.datajet.app/datetimetransform-template-8" --- > ## 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. # SECSDIFF(A,B) ## DateTime Transform: SECSDIFF(A,B) ## Returns difference in seconds between Time for DateTime A and Time for DateTime B SECSDIFF(A,B) = AbsoluteSeconds(B) - AbsoluteSeconds(A) Where AbsoluteSeconds(B) = number of seconds from date reference (where date reference = Jan 0, 0000) to B AbsoluteSeconds(A) = number of seconds from date reference (where date reference = Jan 0, 0000) to A ## Purpose Use this function to: - Calculate time between events down to the second - Calculate the age of an event in seconds ## Return Value | Property | Value | | --- | --- | | **FieldType** | Integer | | **FieldSize** | Med / High / Continuous | | **DataType** | Discrete / Continuous | | **DataSize** | Integer | ```shell Example Return Value: -N....N where N = Max(AbsoluteSeconds(B) - AbsoluteSeconds(A)) ``` ![](https://cdn.document360.io/73b6469b-c1e4-47e9-aa65-986c8ebd17ca/Images/Documentation/DT_SECSDIFF_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. | | **DateTime Function** | “p1”: “SECSDIFF(A,B)” | SECSDIFF(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 ![](https://cdn.document360.io/73b6469b-c1e4-47e9-aa65-986c8ebd17ca/Images/Documentation/DT_SECSDIFF_JSON.PNG) ## Usage Notes Any combination of Field/Immediate value is valid for A and B e.g., `FieldA/#2019-01-02 00:00:00` `#2020-01-02 00:00:00/#2019-01-02 00:00:00` `FieldA/FieldB` `#2020-01-02 00:00:00/FieldB` See Also: - HOURSDIFF(A,B)  (DateTime) - MINSDIFF(A.B)    (DateTime) - Engineering | Expression Field ## Example | Example | Details | | --- | --- | | **Description** | Calculate the number of seconds between purchase and shipping | | **Input** | - Table: = [transactions] - Function: = DateTimeTransform - **DateTimeFunction: = SECSDIFF(A,B)** - A:= [transactions].[dtPurchase] - B: = [transactions].[dtShipping] - Name: =SECSDIFF_AB | | **Sample** | ![](https://cdn.document360.io/73b6469b-c1e4-47e9-aa65-986c8ebd17ca/Images/Documentation/DT_SECSDIFF_Example.png) |