Re: [SQL] Date question

From: clayton cottingham <drfrog(at)smartt(dot)com>
To: Francis Solomon <francis(at)stellison(dot)co(dot)uk>
Cc: Boulat Khakimov <boulat(at)inet-interactif(dot)com>, pgsql-sql(at)postgresql(dot)org, psql-novice(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: [SQL] Date question
Date: 2001-03-06 20:37:27
Message-ID: 3AA54A87.EFA4EDAE@smartt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

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(at)postgresql(dot)org

i dunno about you but i like this syntax better than the old :: ones

select date(now()+ '1 year');

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Simon Crute 2001-03-06 20:47:12 How robust is PostgreSQL
Previous Message Brett W. McCoy 2001-03-06 20:13:34 Re: PHP and PostgresSQL beta

Browse pgsql-sql by date

  From Date Subject
Next Message David Lynn 2001-03-06 22:24:30 Re: Comparing dates
Previous Message Tom Lane 2001-03-06 20:10:52 Re: Problems with RULE