The Timespan data type

A Timespan value represents a duration of time. The Timespan data type matches a specified range of durations and includes all values within the given range. The default represents a positive or negative infinite duration. A Timespan value can be specified with strings or numbers in various forms. The type takes up to two parameters.

Parameters

The full signature for Timespan is:

Timespan[ (<TIMESPAN START OR LENGTH>, (<TIMESPAN END>)) ]
PositionParameterData typeDefault valueDescription
1Timespan start or lengthString, Float, Integer, or defaultdefault (negative infinity in a span) If only one parameter is passed, it is the length of the timespan. If two parameters are passed, this is the start or from value in a time range.
2Timespan endString, Float, Integer, or defaultdefault (positive infinity) or none if only one value passed.The end or to value in a time range.
Timespan values are interpreted depending on their format:
  • A String in the format D-HH:MM:SS represents a duration of D days, HH hours, MM minutes, and SS seconds.

  • An Integer or Float represents a duration in seconds.

A Timespan defined as a range (two parameters) matches any Timespan durations that can fit within that range. If either end of a range is defined as default (infinity), it is an open range, while any other range is a closed range. The range is inclusive.

In other words, Timespan[2] matches a duration of two seconds, but Timespan[0, 2] can match anyTimespan from zero to two seconds, inclusive.

The Timespan type is not enumerable.

For information about converting values of other types to Timespan using the new function, or for converting a Timespan to a String using strftime, see the function reference documentation.

Examples:

Timespan[2]
Matches a Timespan value of 2 seconds.
Timespan[77.3]
Matches a Timespan value of 1 minute, 17 seconds, and 300 milliseconds (77.3 seconds).
Timespan['1-00:00:00', '2-00:00:00']
Matches a closed range of Timespan values between 1 and 2 days.