Re: Query Casting Help - Mailing list pgsql-general

From Richard Huxton
Subject Re: Query Casting Help
Date
Msg-id 200207091152.29695.dev@archonet.com
Whole thread Raw
In response to Query Casting Help  (Hunter Hillegas <lists@lastonepicked.com>)
List 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



pgsql-general by date:

Previous
From: "frank_lupo"
Date:
Subject: problem GMT time
Next
From: Manfred Koizar
Date:
Subject: Re: Query Analyzing