Date question
Hi,
Im a little bit stuck here.
Does anyone know how to get date in format 'YYYY-MM-DD' of a date one
year from now.
So for example today is '2001-03-06' I need to get date 12 months from
now
which will be '2002-03-06' in todays case...
In mysql I used DATE_ADD(CURDATE(), INTERVAL 12 MONTH) , but that
doesnt work in PG.
Regards,
Boulat Khakimov
--
Nothing Like the Sun
How about:
SELECT '2001-03-06'::timestamp + '1 Year';
Hope that helps,
Mike Mascari
-----Original Message-----
From: Boulat Khakimov [SMTP:boulat@inet-interactif.com]
Sent: Tuesday, March 06, 2001 2:20 PM
To: pgsql-sql@postgresql.org; psql-novice@postgresql.org; pgsql-general@postgresql.org
Subject: [GENERAL] Date question
Hi,
Im a little bit stuck here.
Does anyone know how to get date in format 'YYYY-MM-DD' of a date one
year from now.
So for example today is '2001-03-06' I need to get date 12 months from
now
which will be '2002-03-06' in todays case...
In mysql I used DATE_ADD(CURDATE(), INTERVAL 12 MONTH) , but that
doesnt work in PG.
Regards,
Boulat Khakimov
--
Nothing Like the Sun
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly
Import Notes
Resolved by subject fallback
This will do it:
mfork=# SELECT to_char(now() + '1 Year'::interval, 'YYYY-MM-DD');
to_char
------------
2002-03-06
(1 row)
Michael Fork - CCNA - MCP - A+
Network Support - Toledo Internet Access - Toledo Ohio
On Tue, 6 Mar 2001, Boulat Khakimov wrote:
Show quoted text
Hi,
Im a little bit stuck here.
Does anyone know how to get date in format 'YYYY-MM-DD' of a date one
year from now.
So for example today is '2001-03-06' I need to get date 12 months from
now
which will be '2002-03-06' in todays case...In mysql I used DATE_ADD(CURDATE(), INTERVAL 12 MONTH) , but that
doesnt work in PG.Regards,
Boulat Khakimov--
Nothing Like the Sun
Hi Boulat,
stasis=# select (now() + '1 year')::date;
?column?
------------
2002-03-06
(1 row)
Hope this helps
Francis
Show quoted text
Hi,
Im a little bit stuck here.
Does anyone know how to get date in format 'YYYY-MM-DD' of a date one
year from now.
So for example today is '2001-03-06' I need to get date 12 months from
now
which will be '2002-03-06' in todays case...In mysql I used DATE_ADD(CURDATE(), INTERVAL 12 MONTH) , but that
doesnt work in PG.Regards,
Boulat Khakimov
Boulat Khakimov writes:
Does anyone know how to get date in format 'YYYY-MM-DD' of a date one
year from now.
So for example today is '2001-03-06' I need to get date 12 months from
now
which will be '2002-03-06' in todays case...In mysql I used DATE_ADD(CURDATE(), INTERVAL 12 MONTH) , but that
doesnt work in PG.
How about CURRENT_DATE + INTERVAL '12 months'?
--
Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/
you can say:
(now() + '1year'::timespan)::date
Jie LIANG
St. Bernard Software
10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873
jliang@ipinc.com
www.stbernard.com
www.ipinc.com
On Tue, 6 Mar 2001, Boulat Khakimov wrote:
Show quoted text
Hi,
Im a little bit stuck here.
Does anyone know how to get date in format 'YYYY-MM-DD' of a date one
year from now.
So for example today is '2001-03-06' I need to get date 12 months from
now
which will be '2002-03-06' in todays case...In mysql I used DATE_ADD(CURDATE(), INTERVAL 12 MONTH) , but that
doesnt work in PG.Regards,
Boulat Khakimov--
Nothing Like the Sun---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
Francis Solomon wrote:
Hi Boulat,
stasis=# select (now() + '1 year')::date;
?column?
------------
2002-03-06
(1 row)Hope this helps
Francis
Hi,
Im a little bit stuck here.
Does anyone know how to get date in format 'YYYY-MM-DD' of a date one
year from now.
So for example today is '2001-03-06' I need to get date 12 months from
now
which will be '2002-03-06' in todays case...In mysql I used DATE_ADD(CURDATE(), INTERVAL 12 MONTH) , but that
doesnt work in PG.Regards,
Boulat Khakimov---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
i dunno about you but i like this syntax better than the old :: ones
select date(now()+ '1 year');