Re: Query Casting Help - Mailing list pgsql-general

From Robert L Mathews
Subject Re: Query Casting Help
Date
Msg-id 20020709165052.057713FC330@mail1.tigertech.net
Whole thread Raw
In response to Query Casting Help  (Hunter Hillegas <lists@lastonepicked.com>)
List pgsql-general
At 7/8/02 11:51 PM, 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.

The parentheses aren't in quite the right place. Try:

extract(month from (current_date + interval '1 month'))

That is, you want to add 1 month to the current date first (adding a date
and an interval), then extract the month number from the result of that.

Your version extracted the month integer first -- "8" -- then tried
adding an interval to it, but it doesn't make sense to add integers and
intervals together.

------------------------------------
Robert L Mathews, Tiger Technologies


pgsql-general by date:

Previous
From: Joe Conway
Date:
Subject: Re: Returning bytea* from a C function
Next
From: Stephan Szabo
Date:
Subject: Re: update problem?