Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-novicepgsql-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

pgsql-novice by date

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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group