IntervalIntersection

Description

Returns the duration in milliseconds of the overlap between all intervals in the function's arguments.

The interval is represented by a pair of start and end DateTime expressions, and it includes the start end excludes the end (i.e. the interval between 2000-01-01T00:00:00 and 2000-01-01T00:01:00 there are 60 seconds).

Interval A overlaps interval B if interval A's end DateTime is greater than interval B's start DateTime.

This function takes an even number of arguments and returns the duration in milliseconds of the overlap between all intervals. If the intervals do not overlap, then 0 is returned.

Syntax

IntervalIntersection(interval1_start, interval1_end, interval2_start, interval2_end [)

Arguments

  interval1_start - datetime expression representing the start of the first interval. 

  interval1_end - datetime expression representing the end of the first interval.

  interval2_start - datetime expression representing the start of the second interval.

  interval2_end - datetime expression representing the start of the second interval.

  intervalN_start - datetime expression representing the start of the Nth interval. 

  intervalN_end - datetime expression representing the end of the Nth interval.

Examples

IntervalIntersection(ToDate('2013-09-10T08:00:00.000Z'), AddDuration(ToDate('2013-09-10T08:00:00.000Z'),'PT10M'), ToDate('2013-09-10T08:05:00.000Z'), AddDuration(ToDate('2013-09-10T08:05:00.000Z'),'PT10M'))returns 300000 (5 minutes).

Return value datatype

Long

Impact of null value

If any of the inputs is null, returns null.

Feedback and Knowledge Base