Solved

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

Posted on 2007-12-06
3
3,297 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
ID: 20422779
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
ID: 20423068
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
ID: 20424549
date_col + term_col * interval '1 months'
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.

792 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