pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedSQL doubt - Date Add
4+ messages / 3 participants
[nested] [flat]
* SQL doubt - Date Add
@ 2004-10-10 14:19 sreejith s <getsreejith@gmail.com>
2004-10-10 14:36 ` Re: SQL doubt - Date Add Gaetano Mendola <mendola@bigfoot.com>
2004-10-10 14:37 ` Re: SQL doubt - Date Add Gaetano Mendola <mendola@bigfoot.com>
0 siblings, 2 replies; 4+ messages in thread
From: sreejith s @ 2004-10-10 14:19 UTC (permalink / raw)
To: pgsql-sql
Hi friends,
I problem is i want to add a specified no. of years to a
given date
ie, 12/12/2004 + 5 = 12/12/2009. This has to be done via sql. Any
predefined function there for the same. or v have split the yr and
then add.
Sreejith
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: SQL doubt - Date Add
2004-10-10 14:19 SQL doubt - Date Add sreejith s <getsreejith@gmail.com>
@ 2004-10-10 14:36 ` Gaetano Mendola <mendola@bigfoot.com>
2004-10-11 09:21 ` Re: SQL doubt - Date Add Richard Huxton <dev@archonet.com>
1 sibling, 1 reply; 4+ messages in thread
From: Gaetano Mendola @ 2004-10-10 14:36 UTC (permalink / raw)
To: sreejith s <getsreejith@gmail.com>
sreejith s wrote:
> Hi friends,
> I problem is i want to add a specified no. of years to a
> given date
> ie, 12/12/2004 + 5 = 12/12/2009. This has to be done via sql. Any
> predefined function there for the same. or v have split the yr and
> then add.
> Sreejith
>
# select '2004-12-12'::date + 5 * '1 year'::interval;
?column?
---------------------
2009-12-12 00:00:00
(1 row)
Regards
Gaetano Mendola
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: SQL doubt - Date Add
2004-10-10 14:19 SQL doubt - Date Add sreejith s <getsreejith@gmail.com>
2004-10-10 14:36 ` Re: SQL doubt - Date Add Gaetano Mendola <mendola@bigfoot.com>
@ 2004-10-11 09:21 ` Richard Huxton <dev@archonet.com>
0 siblings, 0 replies; 4+ messages in thread
From: Richard Huxton @ 2004-10-11 09:21 UTC (permalink / raw)
To: Gaetano Mendola <mendola@bigfoot.com>; +Cc: sreejith s <getsreejith@gmail.com>; pgsql-sql
Gaetano Mendola wrote:
> sreejith s wrote:
>
>> Hi friends,
>> I problem is i want to add a specified no. of years to a
>> given date
>> ie, 12/12/2004 + 5 = 12/12/2009. This has to be done via sql. Any
>> predefined function there for the same. or v have split the yr and
>> then add.
>> Sreejith
>>
>
> # select '2004-12-12'::date + 5 * '1 year'::interval;
> ?column?
> ---------------------
> 2009-12-12 00:00:00
> (1 row)
But be aware of...
richardh=# SELECT '2004-02-28'::date + '1 year'::interval;
?column?
---------------------
2005-02-28 00:00:00
(1 row)
richardh=# SELECT '2004-02-29'::date + '1 year'::interval;
?column?
---------------------
2005-02-28 00:00:00
(1 row)
richardh=# SELECT '2004-02-29'::date + '4 years'::interval;
?column?
---------------------
2008-02-29 00:00:00
(1 row)
--
Richard Huxton
Archonet Ltd
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: SQL doubt - Date Add
2004-10-10 14:19 SQL doubt - Date Add sreejith s <getsreejith@gmail.com>
@ 2004-10-10 14:37 ` Gaetano Mendola <mendola@bigfoot.com>
1 sibling, 0 replies; 4+ messages in thread
From: Gaetano Mendola @ 2004-10-10 14:37 UTC (permalink / raw)
To: pgsql-sql
sreejith s wrote:
> Hi friends,
> I problem is i want to add a specified no. of years to a
> given date
> ie, 12/12/2004 + 5 = 12/12/2009. This has to be done via sql. Any
> predefined function there for the same. or v have split the yr and
> then add.
> Sreejith
>
# select '2004-12-12'::date + 5 * '1 year'::interval;
?column?
---------------------
2009-12-12 00:00:00
(1 row)
Regards
Gaetano Mendola
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2004-10-11 09:21 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-10-10 14:19 SQL doubt - Date Add sreejith s <getsreejith@gmail.com>
2004-10-10 14:36 ` Gaetano Mendola <mendola@bigfoot.com>
2004-10-11 09:21 ` Richard Huxton <dev@archonet.com>
2004-10-10 14:37 ` Gaetano Mendola <mendola@bigfoot.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox