interval()

Read(3412) Label: interval, datetime value,

Description:

Compute the number of days between two datetime values.

Syntax:

interval (t1,t2)

t1- t2     Equivalent to interval (t2, t1)

Note:

The function computes the number of days between two datetime values t1 and t2.

Parameter:

t1

A date value, datetime value or integer; when it is an integer, it can be understood as value of days@o().

t2

A date value, datetime value or integer; when it is an integer, it can be understood as value of days@o().

Option:

@y

Compute the number of years between two datetime values

@q

Compute the number of quarters between two datetime values

@m

Compute the number of months between two datetime values

@s

Compute the number of seconds between two datetime values

@ms

Compute the number of milliseconds between two datetime values

@r

Compute the interval between two datetime values and return a real number

@w

Compute the number of weeks between two datetime values

@7

Compute the number of Sundays between two datetime values according to a left-open interval

@1

Compute the number of Mondays between two datetime values according to a left-open interval

@r

Work with options @y, @m and @w. Add the duration less than a whole day to the number of whole days as a fractional part; the interval of datetime values is left-open and right-closed.

@ymd

Return result as an integer in the form of ymmdd according to a left-open and right-closed interval.

@ym

Return result as an integer in the form of ymm according to a left-open and right-closed interval.

@md

Return result as an integer in the form of mdd according to a left-open and right-closed interval.

@yd

Return result as an integer in the form of yddd according to a left-open and right-closed interval.

Return value:

Integer

Example:

interval(datetime("19800227","yyyyMMdd"),datetime("1983-02-27 00:00:45"))

1097

interval@y(datetime("19800227","yyyyMMdd"),datetime("1983-02-27 00:00:45"))

3

interval@q(datetime("19800227","yyyyMMdd"),datetime("1983-02-27 00:00:45"))

12

interval@m(datetime("19800227","yyyyMMdd"),datetime("1983-02-27 00:00:45"))

36

interval@s(datetime("19800227","yyyyMMdd"),datetime("1980-02-27 00:00:45"))

45

interval@s ("1972-11-08 10:20:30","1972-11-08 10:30:50")

620

interval@ms(datetime("19800227","yyyyMMdd"),datetime("1980-02-27 00:00:45"))

45,000

interval@ms("1972-11-08 10:20:30","1972-11-08 10:30:50")

620,000

interval@r(datetime("19800227","yyyyMMdd"),datetime("1980-02-27 00:00:45"))

5.208333333333333E-4

interval@r("1972-11-08 10:20:30","1973-11-08 10:30:50")

365.00717592592594

datetime("19850227","yyyyMMdd")-datetime("1983-02-27 00:00:45")

730

interval@w("1972-10-08 10:20:30","1972-11-08 10:30:50")

4

interval@7("1972-10-08 10:20:30","1972-11-08 10:30:50")

4

interval@1("1972-10-08 10:20:30","1972-11-08 10:30:50")

5

interval@y(15899,23545)

20

interval@y(date@o(15899),date@o(23545))

20

interval@ry("2023-11-26","2024-12-05")

1.0273972602739727

interval@rm("2023-11-26","2024-12-05")

12.5

interval@rw("2023-11-26","2024-12-05")

53.57142857142857

interval@ymd("2021-07-26","2024-12-05")

30409

interval@ym("2021-07-26","2024-12-05")

304

interval@yd("2021-07-26","2024-12-05")

3132

interval@md("2021-07-26","2024-12-05")

4009