Re: How to add days to date

Поиск
Список
Период
Сортировка
Искать
От
Michael Fuhr
Тема
Re: How to add days to date
Дата
Msg-id
20060816011656.GA3453@winnie.fuhr.org
Ответ на
How to add days to date (Alejandro Michelin Salomon \( Adinet \))
Список
Дерево обсуждения
How to add days to date "Alejandro Michelin Salomon \( Adinet \)" <alejmsg@adinet.com.uy>
Re: How to add days to date Michael Fuhr <mike@fuhr.org>
RES: How to add days to date "Alejandro Michelin Salomon \( Adinet \)" <alejmsg@adinet.com.uy>
Re: How to add days to date Alban Hertroys <alban@magproductions.nl>
On Tue, Aug 15, 2006 at 10:10:27PM -0300, Alejandro Michelin Salomon ( Adinet ) wrote:
> EX :
> '2006-08-01' + 30 + ( 7 * ( 3 - 1 )) ==> '2006-08-01' + 44
> 
> All my trys fails.

The error message hints at what's wrong:

test=> SELECT '2006-08-01' + 30 + (7 * (3 - 1));
ERROR:  invalid input syntax for integer: "2006-08-01"

PostgreSQL doesn't know that the untyped string is supposed to be
interpreted as a date.  Use a cast:

test=> SELECT '2006-08-01'::date + 30 + (7 * (3 - 1));
  ?column?  
------------
 2006-09-14
(1 row)

or

test=> SELECT CAST('2006-08-01' AS date) + 30 + (7 * (3 - 1));
  ?column?  
------------
 2006-09-14
(1 row)

-- 
Michael Fuhr
В списке pgsql-general по дате отправления
От: Alejandro Michelin Salomon \( Adinet \)
Дата:
Сообщение: How to add days to date
От: Michael Fuhr
Дата:
Сообщение: Re: Connection string
FAQ