elapse()

Read(263) Label: new date, year, quarter, month, day,

Description:

Get the date/time which is a certain time period before or after a given date/time.

Syntax:

elapse(dateExp, n)

dateExp± n   elapse(dateExp, n)

Note:

The function computes the new date which is n days/n months/n years before or after the date dateExp. When getting the same date in last year according to the specified date, if the desired date does not exist, then return the last day of the same month. For example, elapse@m("2009-03-31",-1) returns 2009-02-28.

Parameters:

dateExp

A specified date expression that should return a date or a string of standard date format.

n

An integer expression according to which a date/time n days/years/months/seconds after or before a given date/time is computed, depending on whether n is positive or negative.

Options:

@y

Compute the date which is n years before or after the specified date.

@q

Compute the date which is n quarters before or after the specified date.

@m

Compute the date which is n months before or after the specified date.

@e

If the specified date is the last day of a month, the new date will not be adjusted to the last day of the month to which it belongs. Without the option the new date will be automatically adjusted to the last day of the corresponding month. This option works with @yqm.

@s

Compute the datetime which is n seconds before or after the specified datetime

@ms

Compute the datetime which is n milliseconds before or after the specified datetime; by default the function computes the date which is n days after the specified date.

 

 

Return value:

Datetime

Example:

elapse(datetime("19800227","yyyyMMdd"),5)

1980-03-03 00:00:00

elapse@s(datetime("19800227","yyyyMMdd"),5)

1980-02-27 00:00:05

elapse@ms(datetime("19800227","yyyyMMdd"),5)

1980-02-27 00:00:00

elapse(datetime("19800227","yyyyMMdd"),-3)

1980-02-24 00:00:00

elapse@y(datetime("19800227","yyyyMMdd"),-3)

1977-02-27 00:00:00

elapse@q(datetime("19800227","yyyyMMdd"),-3)

1979-05-27 00:00:00

elapse@m(datetime("19800227","yyyyMMdd"),-3)

1979-11-27 00:00:00

elapse@s(datetime("19800227","yyyyMMdd"),-3)

1980-02-26 23:59:57

elapse@ms(datetime("19800227","yyyyMMdd"),-3)

1980-02-26 23:59:59

datetime("19800227","yyyyMMdd")+5

1980-03-03 00:00:00

datetime("19800227","yyyyMMdd")-5

1980-02-22 00:00:00

elapse@y(datetime("19770228","yyyyMMdd"),3)

1980-02-29 00:00:00

elapse@ey(datetime("19770228","yyyyMMdd"),3)

1980-02-28 00:00:00

elapse@q(datetime("19800229","yyyyMMdd"),1)

1980-05-31 00:00:00

elapse@eq(datetime("19800229","yyyyMMdd"),1)

1980-05-29 00:00:00

elapse@m(datetime("19800229","yyyyMMdd"),5)

1980-07-31 00:00:00

elapse@em(datetime("19800229","yyyyMMdd"),5)

1980-07-29 00:00:00