Kung Fu Kung Fu

Fujian White Crane Kung Fu

Zope Zope

What I have and am doing with Zope

Photos Photos

Photoalbum, both old and new.

Receptsamlingen Receptsamlingen

In Swedish only. About my "Collection of Recipes" website.

Contact me Contact me

My contact details and how to contact me.

  Mobile version of this page Mobile version of this page


 

Adding a year in PostgreSQL

http://www.postgresql.org/docs/7.4/s...tml#OPERATORS-DATETIME-TABLE

postgresql, interval, timestamp

4th of February 2004

Finally I found it. How to add one year to a date in PostgreSQL

 SELECT 
  date('now') + interval '1 year' AS today_in_one_year,
  date '2003-12-13' + interval '1 year' AS my_next_birthday ;

Both return a TIMESTAMP type.


Comment

Peter - 27th August 2004  [«« Reply to this]
UPDATE: It doesn't return a TIMESTAMP type, it's a DATE type (only 4 bytes).

To get a TIMESTAMP you can do this:

SELECT '2003-12-13' + interval '1 year' AS my_next_birthday;
 
Name:
Email:
hide my email address.

Your email address will be encoded to prevent email-extraction spiders from reading it so you won't get spammed if you decide to show your email address.