calculate-time-difference

Calculates the time difference (in a specified unit of measurement) between two datatable columns

Takes two datetime columns in a datatable and calculates the time difference between them. You can specify the unit of measurement to use in calculating the difference (e.g. minutes, hours, days, etc.)

[Reference column]-[Value column]=difference value

If the difference value (contained in target column ) is negative, then the date-time in value column occurred after the date-time in reference column.

Arguments

Inputs:

data: The datatable containing two date-time columns.

Reference column: The name of the first column containing reference date-time values (this is the date-time that happened later in time).

Reference format: The format of data in reference column based on Unicode Technical Standard #35: https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table. If unspecified, defaults to ISO 8601 date/time.

Value column: The name of the second column containing date/time values (this is the date-time that happened earlier in time).

Value format: The format of data in value column based on Unicode Technical Standard #35: https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table Defaults to ISO 8601 date/time.

Target column: The name of the new column containing time difference values. TIP: include the difference unit in the column name.

Difference unit: The unit of time measurement. If unspecified, defaults to days. Options include "years", "quarter", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds

Output:

data: The new datatable with the new target column containing time difference values.

Example

Possible use cases

  • Determining turnaround time for parts of a process with logged timepoints (e.g. the time between collection of a sample and obtaining sequencing data on that sample)

  • Determine which of two events occurred first, by noting whether the output is positive or negative.

Last updated