Date question
Date question
От:
Boulat Khakimov <boulat@inet-interactif.com>
Дата:
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
RE: Date question
От:
"Francis Solomon" <francis@stellison.co.uk>
Дата:
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
Re: Date question
От:
Michael Fork <mfork@toledolink.com>
Дата:
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: > 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 >
Re: [GENERAL] Date question
От:
Peter Eisentraut <peter_e@gmx.net>
Дата:
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/
Re: Date question
От:
Jie Liang <jliang@ipinc.com>
Дата:
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: > 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) >
Re: Date question
От:
clayton cottingham <drfrog@smartt.com>
Дата:
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');