At 10:02 PM 1/14/00 -0400, The Hermit Hacker wrote:
>
>I can add days to now(), but not subtract?
>
>=====================================
>
>template1=> select now() + '30 days';
> ?column?
>------------------------------
> Sun Feb 13 22:00:33 2000 AST
>(1 row)
>
>template1=> select now() - '30 days';
>ERROR: Unable to identify an operator '-' for types 'timestamp' and
'unknown'
> You will have to retype this query using an explicit cast
>template1=> select version();
donb=> select now()-'30 days'::reltime;
?column?
----------------------
1999-12-15 18:13:18-08
(1 row)
donb=> select now()-'30 days';
ERROR: Unable to identify an operator '-' for types 'timestamp' and 'unknown' You will have to retype this query
usingan explicit cast
donb=>
As a relative newcomer, I too have found dates a bit confusing and
my solution has been to cast like crazy rather than guess what will
happen if I don't :)
- Don Baccus, Portland OR <dhogaza@pacifier.com> Nature photos, on-line guides, Pacific Northwest Rare Bird Alert
Serviceand other goodies at http://donb.photo.net.