interval()

Read(3353) 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

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