Re: dates

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: dates
Дата
Msg-id 21255.1147885531@sss.pgh.pa.us
обсуждение исходный текст
Ответ на dates  (John Ensign <john@deepsnow.org>)
Список pgsql-novice
John Ensign <john@deepsnow.org> writes:
> select to_date( textfield1, 'MM-DD-YYYY') as startDate, CAST
> ( textfield2, int4) as duration, startDate + duration as endDate.

That's got at least two problems: one, that's not the syntax of CAST,
you need to write CAST(textfield2 AS int4); and two, you can't reference
a SELECT output column from another column like that.  You could write

select
    to_date(textfield1, 'MM-DD-YYYY') as startDate,
    CAST(textfield2 AS int4) as duration,
    to_date(textfield1, 'MM-DD-YYYY') + CAST(textfield2 AS int4) as endDate
from whatever ...

            regards, tom lane

В списке pgsql-novice по дате отправления:

Предыдущее
От: John Ensign
Дата:
Сообщение: dates
Следующее
От: "atsorgassa"
Дата:
Сообщение: insert performance