Solved

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

Posted on 2007-12-06
3
3,350 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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