offset_months
function adds months to the month component of the date, if the resulting month doesn't have enough days for the day component, the last day of the new month is returned.
Syntax
offset_months(date(year, month, day), months)
Parameters
date
can be any of the following:- Another function that returns a date.
- A formula column that returns a date.
year
: 4 digits.
For example, 2012month
: 2 digits.
For example, 01 or 12day
: 2 digits.
For example, 01 or 30months
:- Positive: Counts forwards
- Negative: Counts backwards
Examples
offset_months(date(2020,12, 25), 5)
returns 25 May 2021