Appearance
ADD_MONTHS
Add some number of months to a date or timestamp expression. (You can also subtract months by using a negative number for the second argument.)
ADD_MONTHS(expression, number)
For example:
premdb=# select matchday, add_months(matchday,6) from match where htid=2 and atid=60;
matchday | add_months
---------------------+---------------------
2010-03-06 00:00:00 | 2010-09-06 00:00:00
(1 row)
premdb=# select matchday, add_months(matchday,-6) from match where htid=2 and atid=60;
matchday | add_months
---------------------+---------------------
2010-03-06 00:00:00 | 2009-09-06 00:00:00
(1 row)
If the month in the result has fewer days, the function returns the last day of the month. In other cases, the result contains the same day of month number as the input expression.
If either argument is null
, the result is null
.
Note: You cannot use the ADD_MONTHS
function in queries against system views.
Parent topic:Datetime Functions