| From: | nzanella(at)cs(dot)mun(dot)ca (Neil Zanella) |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: incrementing and decrementing dates by day increments programmatically |
| Date: | 2003-10-27 09:40:53 |
| Message-ID: | b68d2f19.0310270140.72c274a9@posting.google.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
alvherre(at)dcc(dot)uchile(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Miso Hlavac | 2003-10-27 11:28:32 | function with tablename parameter |
| Previous Message | Neil Conway | 2003-10-27 09:18:53 | Re: explicit casting required for index use |