• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4289
  • Last Modified:

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.

0
Brian_Sutherland
Asked:
Brian_Sutherland
1 Solution
 
ivanovnCommented:
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

0
 
Brian_SutherlandAuthor Commented:
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'  


0
 
earth man2Commented:
date_col + term_col * interval '1 months'
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now