Solved

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

Posted on 2007-12-06
3
3,146 Views
Last Modified: 2012-05-05
I am looking for the syntax for the date function that works like dateadd in sql server that I can use in PostgreSQL.

0
Comment
Question by:Brian_Sutherland
3 Comments
 
LVL 10

Expert Comment

by:ivanovn
Comment Utility
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
 

Author Comment

by:Brian_Sutherland
Comment Utility
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
 
LVL 22

Accepted Solution

by:
earth man2 earned 50 total points
Comment Utility
date_col + term_col * interval '1 months'
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Suggested Solutions

Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: http://www.postgresql.org/ (http://www.postgresql.org/) This requires some add-o…
Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now