From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | stan <stanb(at)panix(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Problems with using function input paramaters |
Date: | 2019-08-31 15:13:30 |
Message-ID: | 23260.1567264410@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> On Sat, Aug 31, 2019 at 7:05 AM stan <stanb(at)panix(dot)com> wrote:
>> CURRENT_DATE) - interval ' $1
>> month - 1
>> ' day as date)
> ($1 || ' month')::interval -- should work
FWIW, I tend to prefer doing it with interval arithmetic, like this:
$1 * '1 month'::interval - '1 day'::interval
It's faster (not enormously so, but measurably) thanks to not having
to construct and then parse a text string. To my mind it's easier
to reason about, too, and a bit safer.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | stan | 2019-08-31 15:45:09 | echo work alike in SQL |
Previous Message | David G. Johnston | 2019-08-31 14:45:25 | Re: Problems with using function input paramaters |