Re: [SQL] Arithmetic operation on DATE

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: macky <macky(at)edsamail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] Arithmetic operation on DATE
Date: 2001-08-13 10:11:13
Message-ID: 20010813121113.A1336@zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice pgsql-sql

On Mon, Aug 13, 2001 at 05:48:57PM +0800, macky wrote:
> is it possible to add a date datatype column to a number resulting to a
> date......
>
>
> theoretically it should do this,,,
>
> X is in months
>
> date + X = date
>
> --> 2001-08-20 + 6 = 2002-02-20

test=# select '2001-08-20'::date + '6months'::interval;
?column?
------------------------
2002-02-20 00:00:00+01
(1 row)

..see docs about the "interval" datetype.

Karel

--
Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
http://home.zf.jcu.cz/~zakkr/

C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message David Mulcahy 2001-08-13 16:57:49 Foreign Key problem
Previous Message Christopher Sawtell 2001-08-13 10:03:40 Re: [SQL] Arithmetic operation on DATE

Browse pgsql-sql by date

  From Date Subject
Next Message Laurent Martelli 2001-08-13 13:13:17 Re: Donations?
Previous Message Christopher Sawtell 2001-08-13 10:03:40 Re: [SQL] Arithmetic operation on DATE