Crosstips.org

My fun Crossword solver project. Crosstips.org & Krysstips.se

Kung Fu

Fujian White Crane Kung Fu

Fry-IT

Fry-IT is the company I work for

Photos

Photoalbum, both old and new.

Zope

What I have and am doing with Zope

Receptsamlingen

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

Contact me

My contact details and how to contact me.

 

Interested in buying ad space on this blog?
You can, on BuySellAds.com

KungFuPeople.com
Do you train Kung Fu?
Or know someone who does?
Then check out KungFuPeople.com


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

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.