Re: Query Casting Help

Поиск
Список
Период
Сортировка
От Thomas Lockhart
Тема Re: Query Casting Help
Дата
Msg-id 3D2AF123.4B8EC067@fourpalms.org
обсуждение исходный текст
Ответ на Query Casting Help  (Hunter Hillegas <lists@lastonepicked.com>)
Список 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 по дате отправления:

Предыдущее
От: Chris Albertson
Дата:
Сообщение: RelationClearRelation: relation X deleted while still in use???
Следующее
От: Tom Lane
Дата:
Сообщение: Re: problem GMT time