Calculate Date Time Difference

This activity calculates the difference between two Date Time values. It returns two sets of variables; one set represents the difference between the two dates and the other represents the total amount of time between the two in various units of time.

Usage

This activity expects two inputs:

  • Original Datetime - The datetime from which another date is subtracted. You can provide this date as a string or from a Date Time variable.

  • Subtract Datetime - The date to subtract from the original. You can provide as a string or from a Date Time variable.

Example:

If the Original Datetime is 2020-12-02T10:00:00Z and the Subtract Datetime is 2020-12-01T10:00:00+00:00, we will receive the outputs below.

The first set of variables represent the difference between the two date times. When these variables are added together, it equals the total amount of time between the two inputs:

Variable Name Sample Output
Days 1
Hours 0
Minutes 0
Seconds 0
Milliseconds 0

The second set of variables represents the total amount of time between the two inputs, but in different units of time:

Variable Name Sample Output
Total Days 1
Total Hours 24
Total Minutes 1440
Total Seconds 86400
Total Milliseconds 86400000

Supported Date Formats

The following date formats can be used as input into this activity. You can also use a DateTime variable.

Format Name Example
ANSIC Mon Jan 2 15:04:05 2018
UnixDate Mon Jan 2 15:04:05 MST 2018
RubyDate Mon Jan 02 15:04:05 -0700 2018
RFC822 02 Jan 18 15:04 MST
RFC822Z 02 Jan 18 15:04 -0700
RFC850 Monday, 02-Jan-18 15:04:05 MST
RFC1123 Mon, 02 Jan 2018 15:04:05 MST
RFC1123Z Mon, 02 Jan 2018 15:04:05 -0700
RFC3339 2018-01-02T15:04:05-07:00
RFC3339Nano 2018-01-02T15:04:05.999999999-07:00
Custom Formats
  • 2018-01-02

  • 02-01-2018

  • 20180102-150405

  • 02012018-150405 (European time format)

Note: In European time format, 01 always stands for Month and 02 stands for Day.

Sample Workflows

The following sample workflows are available in our repository’s workflows folder to help you get familiar with this concept. These can be imported using the instructions in Import Git Content or you can click the workflow to view it in GitHub.