Link to home
Start Free TrialLog in
Avatar of Brian_Sutherland
Brian_Sutherland

asked on

What is the equivalent date function in postgreSQL for add_months or DateAdd

I am looking for the syntax for the date function that works like dateadd in sql server that I can use in PostgreSQL.

Avatar of ivanovn
ivanovn
Flag of United States of America image

You could use the overloaded arithmetic in PostgreSQL to achieve the same result. For example if you wanted to add one day to a given date you would do something similar to the code below.

Read http://www.postgresql.org/docs/8.2/interactive/functions-datetime.html for more info.

date '2007-12-06' + interval '1 day'

Open in new window

Avatar of Brian_Sutherland
Brian_Sutherland

ASKER

Thanks, what if I had a column called term that held  the number of months I want to add?
Would it be:
<date filed> + interval '<term> months'  


ASKER CERTIFIED SOLUTION
Avatar of earth man2
earth man2
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial