URL: http://www.postgresql.org/docs/7.4/static/functions-datetime.html#OPERATORS-DATETIME-TABLE

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.

Comments

Peter

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;

Your email will never ever be published.

Previous:
PayPalSucks.com, can't be good for PayPal February 4, 2004 Web development
Next:
Techie things I want to buy from ebuyer.com February 5, 2004 Wondering
Related by category:
set -ex - The most useful bash trick of the year August 31, 2014 Linux
brotli_static in Nginx November 8, 2024 Linux
Be very careful with your add_header in Nginx! You might make your site insecure February 11, 2018 Linux
Linux tip: du --max-depth=1 September 27, 2007 Linux
Related by keyword:
Adding client-to-server sync to PissueTracker March 20, 2025 React, JavaScript, Bun
Connecting with psycopg2 without a username and password February 24, 2011 Python
UPPER vs. ILIKE April 19, 2010 Web development
How I performance test PostgreSQL locally on macOS December 10, 2018 Web development, PostgreSQL, macOS