Re: Query Casting Help - Mailing list pgsql-general

From Thomas Lockhart
Subject Re: Query Casting Help
Date
Msg-id 3D2AF123.4B8EC067@fourpalms.org
Whole thread Raw
In response to Query Casting Help  (Hunter Hillegas <lists@lastonepicked.com>)
List pgsql-general
> (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.
> Which side should I be casting? To what datatype?

What are you hoping to get as a result? A date, or an interval? The
extract() function returns a double-precision value for the field (the
month in this case) so doesn't give anything for the interval to work
with.

If you want a date, then you might want something like

(date_trunc('month', current_date) + interval '1 month')

hth

                  - Thomas

pgsql-general by date:

Previous
From: Chris Albertson
Date:
Subject: RelationClearRelation: relation X deleted while still in use???
Next
From: Tom Lane
Date:
Subject: Re: problem GMT time