This function computes the number of milliseconds in a certain fixed time period. It is used to make timestamp comparisons easier, more readable and less error-prone.

ParameterTypeRequiredDefault ValueDescription
asstringoptional[a] _duration The name of the output field.
duration[b]stringrequired   The time duration specification. It is defined as a Relative Time Syntax such as 5m or 2d.

[a] Optional parameters use their default value unless explicitly set.

[b] The parameter name duration can be omitted.

Hide omitted argument names for this function

Show omitted argument names for this function

The function returns (in the field selected by the as argument) the number of milliseconds in the duration described by the duration argument. The syntax and semantics of the duration argument is exactly the duration specification mini-language used elsewhere in the system; for more information on time duration, see Relative Time Syntax.

duration() Examples

Click + next to an example below to get the full details.

Compare Two Timestamps

Narrow the Search Interval