Re: Query Casting Help

From: Richard Huxton <dev(at)archonet(dot)com>
To: Hunter Hillegas <lists(at)lastonepicked(dot)com>, PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Query Casting Help
Date: 2002-07-09 10:52:29
Message-ID: 200207091152.29695.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tuesday 09 Jul 2002 12:21 am, Hunter Hillegas wrote:
> I am trying to execute this little bit:
>
> (extract(month from current_date) + interval '1 month')
>
> The system says I need to cast because it can't figure out how to add
> these... I read through the manual and I am still a little confused.

Try:

select extract(month from (current_date + interval '1 month'));
date_part
-----------
8

You want to add an interval to a date. It probably doesn't make sense to add
an interval to a month.

Alternatively:

select extract(month from (current_date)) + 1;

But that wouldn't deal with wrap-around in December.

- Richard Huxton

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Holger Klawitter 2002-07-09 11:05:10 Re: Select in update
Previous Message Manfred Koizar 2002-07-09 09:52:08 Re: Select in update