DTDURATION

Purpose:

Calculates the difference of date and time series in seconds.

Syntax:

DTDURATION(date1, time1, date2, time2)

date1

-

A series of Julian integer dates, the end dates.

time1

-

A series of time of day values, the end times.

date2

-

Optional. A series of Julian integer dates, the start dates. Defaults to an empty series.

time2

-

Optional. A series of time of day values, the start times. Defaults to an empty series.

 

Alternate Syntax:

DTDURATION(datetime1, datetime2)

datetime1

-

An array, the end datetimes where the date and time values are in adjacent columns.

datetime2

-

Optional. An array, the start datetimes where the date and time values are in adjacent columns. Defaults to an empty array.

Returns:

A series, the elapsed duration in seconds.

 

If only one date and time series or one composite datetime series is specified, the durations are computed on the two-point difference of each datetime value.

Example:

W1: ymdhms2dt(2027, 1, 2, 12, 0, 0)

W2: ymdhms2dt(2027, 3, 1, 12, 0, 0)

W3: dtduration(w2, w1)

W4: dtoffset(w1, w3)

 

W1 contains the datetime:

 

1/02/2027 12:00:00

 

W2 contains the datetime:

 

3/01/2027 12:00:00

 

W3 computes the difference between the two datetimes in seconds. The duration is 5011200 seconds.

 

W4 calculates the end datetime by adding the time offset in W3 to the start datetime in W1.

Example:

W1: ymdhms2dt(2028, 1, 2, 12, 0, 0)

W2: ymdhms2dt(2028, 3, 1, 12, 0, 0)

W3: dtduration(w2, w1)

W4: dtoffset(w1, w3)

 

Same as the first example, except the end and start year is 2028, a leap year. The duration is 5097600 seconds. The duration has increased by 86400 seconds from 5011200 seconds to 5097600 because of the leap year.

Example:

W1: ymdhms2dt(2027, 1, 2, 12, 0, 0)

W2: ymdhms2dt(2027, 3, 1, 12, 0, 0)

W3: dtduration(w1, w2)

W4: dtoffset(w2, w3)

 

Same as the first example above, except the start and end date times are swapped. The result is a negative duration of -5011200 seconds.

W4 calculates the earlier end datetime in W1 by subtracting the time offset in W3 from the later start datetime in W2.

Example:

W1: gnorm(10, hours2seconds(2) + minutes2seconds(10) + 13.5)

W2: getdt(w1)

W3: dtduration(w2)

W4: w3;setvunits("Real Time")

 

W1 contains 10 random samples with a time spacing of 7813.5 seconds or 2 hours 10 minutes and 13.5 seconds between samples.

 

W2 computes the datetime values for each sample in W1.

 

Because only one datetime series was given, W3 computes the two-point difference between subsequent samples of W2. The result is 7813.5 seconds for each sample, equal to the original sample spacing of the series in W1.

 

W4 displays the durations in W3 in wall-clock time. The values conform to the time spacing of W1.

Remarks:

DTDURATION computes the difference between two date time series with the result in seconds.

 

A datetime series consists of 2 columns of values where the first column contains integer Julian dates starting at midnight and the second column contains time in seconds starting from midnight.

 

If only one date and time series or one composite date time series is provided, the two-point difference between subsequent date time series values is computed.

 

A datetime duration is measured in seconds.

 

A datetime period is measured in years, months, days, hours, minutes and seconds.

 

See DTPERIOD to compute the time difference in years, months, days, hours, minutes and seconds.

See Also:

DATEDURATION

DTDIFF

DTOFFSET

DTPERIOD

TIMEDURATION

YMDHMS2DT