timeDiffDT#

Purpose#

Computes the difference between two dates in DT scalar format.

Format#

diff = timeDiffDT(dt_1, dt_2, units)#
Parameters:
  • dt_1 (NxK matrix) – containing 1 or more DT scalars.

  • dt_2 (scalar) – the second date.

  • units (string) –

    indicating the units in which to report the difference.

    Valid unit options:

    • ”days”

    • ”hours”

    • ”minutes”

    • ”seconds”

Returns:

diff (Scalar) – the difference between dt_1 and dt_2 in terms of the specified units.

Examples#

// February 14, 1979 at 12:30:21
dt_1 = 19790214123021;

// February 14, 1979 at 18:30:21
dt_2 = 19790214183021;

// Compute the difference in terms of hours
diff = timeDiffDT(dt_1, dt_2, "hours");

The above code will set diff equal to:

-6
// April 15, 1947 19:30:00
dt_1 = 194704151930;

// April 15, 1947 07:53:00
dt_2 = 194704150753;

// Increment by 18 months
diff = timeDiffDT(dt_1, dt_2, "minutes");

The above code will set diff equal to:

697
// December 31, 2000 at 22:59:00
// December 31, 2000 at 23:59:00
dt_1 = { 20001231225900, 20001231235900 };

// January 1, 2001 at 02:13:00
dt_2 =   20010101021300;

// Find the time difference between the dates
diff = timeDiffDT(dt_1, dt_2, "minutes");

The above code will set diff equal to:

-194
-134

See also

Functions timeDeltaPosix(), seqadt(), seqaposix()