Re: incrementing and decrementing dates by day increments programmatically

Поиск
Список
Период
Сортировка
От nzanella@cs.mun.ca (Neil Zanella)
Тема Re: incrementing and decrementing dates by day increments programmatically
Дата
Msg-id b68d2f19.0310270140.72c274a9@posting.google.com
обсуждение исходный текст
Ответ на incrementing and decrementing dates by day increments programmatically  (nzanella@cs.mun.ca (Neil Zanella))
Ответы Re: incrementing and decrementing dates by day increments programmatically
Список pgsql-general
alvherre@dcc.uchile.cl (Alvaro Herrera) wrote in message

> Certainly.  Try the following:
> SELECT now() + 5 * '1 day'::interval;
>
> Or, more verbose,
> SELECT now() + 5 * CAST('1 day' AS interval);
>
> You can of course do
> SELECT now() + CAST('5 day' AS interval);
>
> But the two previous examples can be more easily constructed in an SQL or
> PL/pgSQL function.

Perhaps I should get myself a copy of the relevant parts of the SQL 99 standard.
How would you do the above in standard SQL?

> For the date -I format you can use something like
> SELECT to_char(now() + 5 * '1 day'::interval, 'YYYY-MM-DD');

I believe Oracle also has a to_char() function. Is this to_char() function
part of standard SQL or is it just a coincidence that both DBMSs support
such a function call? I wonder whether the PostgreSQL to_char()
function is compatible with the Oracle one.

Thanks,

Neil

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

Предыдущее
От: pub.lim.1.kp.pieper@ibeq.com (Klaus P. Pieper)
Дата:
Сообщение: Experience with PL/xx?
Следующее
От: Sergei Levchenko
Дата:
Сообщение: connectby