Re: incrementing and decrementing dates by day increments programmatically - Mailing list pgsql-general

From nzanella@cs.mun.ca (Neil Zanella)
Subject Re: incrementing and decrementing dates by day increments programmatically
Date
Msg-id b68d2f19.0310270140.72c274a9@posting.google.com
Whole thread Raw
In response to incrementing and decrementing dates by day increments programmatically  (nzanella@cs.mun.ca (Neil Zanella))
Responses Re: incrementing and decrementing dates by day increments programmatically
List 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 by date:

Previous
From: pub.lim.1.kp.pieper@ibeq.com (Klaus P. Pieper)
Date:
Subject: Experience with PL/xx?
Next
From: Sergei Levchenko
Date:
Subject: connectby