From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | mel(at)gmanmi(dot)tv |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: help: now() + N is now failing! |
Date: | 2003-07-29 14:29:43 |
Message-ID: | 21862.1059488983@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
"Mel Jamero" <mel(at)gmanmi(dot)tv> writes:
> help. does anybody know how, without using date_pli, i can make now() + N
> work in newer versions of postgres?
Sure, make a custom operator.
regression=# select now() + 5;
ERROR: operator does not exist: timestamp with time zone + integer
HINT: No operator matches the given name and argument type(s). You may need to
add explicit typecasts.
regression=# create function tstz_plus_int(timestamp with time zone, int)
regression-# returns date as
regression-# 'select $1::date + $2' language sql;
CREATE FUNCTION
regression=# create operator + (
regression(# procedure = tstz_plus_int,
regression(# leftarg = timestamp with time zone,
regression(# rightarg = int);
CREATE OPERATOR
regression=# select now() + 5;
?column?
------------
2003-08-03
(1 row)
regression=#
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Dmitry Tkach | 2003-07-29 14:33:09 | Re: help: now() + N is now failing! |
Previous Message | Mel Jamero | 2003-07-29 11:24:38 | FW: Retrieving NULL records |