interval()

Read(305) Label: interval, datetime value,

Description:

Compute the interval between two datetime values

Syntax:

interval (datetimeExp1,datetimeExp2)

datetimeExp1- datetimeExp2     

interval (datetimeExp2,datetimeExp1)

Note:

The function computes the interval between two datetime values datetimeExp1 and datetimeExp2

Parameters:

datetimeExp1

The date expression whose value is a datetime or a string of standard datetime format

datetimeExp2

The date expression whose value is a datetime or a string of standard datetime format

Options:

@y

Compute the years between two datetime values

@q

Compute the quarters between two datetime values

@m

Compute the months between two datetime values

@s

Compute the seconds between two datetime values

@ms

Compute the milliseconds between two datetime values

@r

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

 

By default it computes the days between two datetime values

@w

Compute the 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"))

1096

 

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")

731

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

 

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

 

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