DateOffsetByComponents function
Returns the given date, with offsets applied from the given year offset, month offset, and day of month offset, given as three separate values. The offset values can each be positive, zero, or negative.
Namespace
datetime
Input
baseline date(date
), year offset(int
), month of year offset(int
), day of month offset(int
)
Output
date (date
)
Example
If basedate
contains 2011-08-18
and yearoffset
contains the value 2
, monthoffset
contains the value 0
, and dayofmonthoffset
contains the value 0
, then the two following functions are equivalent, and return the date 2013–08–18
.
set-column result datetime:DateOffsetByComponents('2011-08-18',2,0,0)
set-column result datetime:DateOffsetByComponents(basedate,yearoffset,monthoffset,dayofmonthoffset)
If basedate
contains 2011-08-18
and yearoffset
contains the value -2
, monthoffset
contains the value 0
, and dayofmonthoffset
contains the value 0
, then the two following functions are equivalent, and return the date 2009–08–18
.
set-column result datetime:DateOffsetByComponents('2011-08-18',-2,0,0)
set-column result datetime:DateOffsetByComponents(basedate,yearoffset,monthoffset,dayofmonthoffset)
Created in 2020 by Google Inc.