Skip to content

Calculate date difference

Description

The Calculate Date Difference activity computes the difference between two date columns and stores the result in a new column. Users can choose from various units like years, months, days, hours, etc., and optionally retain the original data in the output.

This is useful for calculating metrics like age, duration since last access, time until graduation, and more.

Use this activity to:

  • Measure elapsed time between two date fields.
  • Create duration-based features (e.g., age, time since event).
  • Retain original data alongside calculated fields if needed.

Use case: You can use this activity to calculate the number of years between a student’s enrollment and graduation dates, or find how long ago a customer last accessed your platform.

Input

  • Data – Required. Tabular data containing two date columns for comparison.

Output

Output TypeFormatDescription
DataJSONTransformed data with difference field

Configuration Fields

Field NameDescription
Start DateColumn containing the starting date.
End DateColumn containing the ending date.
Difference UnitsThe unit of time to calculate the difference in. Options include: years, months, days, hours, etc.
Output ColumnName of the column where the calculated difference will be stored.
Include OriginalIf enabled, includes all original input data along with the new calculated column.

Sample Input

idnameenrollmentDatelastAccessdobgraduationDateEnrollment date new
1Alice Johnson2023-01-1501/15/20232002-05-10T00:00:002026-05-1501/15/2023
2Bob Smith15-02-202315-Feb-20232003/04/122027-05-2002/15/2023
3Charlie Brown2023.03.1010 Mar 202310-06-20012025-12-30T23:59:5903/10/2023
4Daisy Adams2023/04/01April 1, 20232000-09-21T12:30:00Z2024/06/1504/01/2023
5Ethan Carter05-May-20232023-05-101999.12.152024-11-0105/05/2023

Sample Configuration

FieldValue
Start DateenrollmentDate
End DategraduationDate
Difference UnitsYears
Output ColumnTotal years
Include Originaltrue

Sample Output

idnameenrollmentDatelastAccessdobgraduationDateEnrollment date newTotal years
1Alice Johnson2023-01-1501/15/20232002-05-10T00:00:002026-05-1501/15/20233.33
2Bob Smith15-02-202315-Feb-20232003/04/122027-05-2002/15/20234.26
3Charlie Brown2023.03.1010 Mar 202310-06-20012025-12-30T23:59:5903/10/20232.81
4Daisy Adams2023/04/01April 1, 20232000-09-21T12:30:00Z2024/06/1504/01/20231.21
5Ethan Carter05-May-20232023-05-101999.12.152024-11-0105/05/20231.50