I'm currently using PostgreSQL 8.4 and need to substract from now()
date on day. What I tried is now() - 1
and it didn't work. Although that page said that we could use operator -
to perform operations on date. More preciseli I recieved
ERROR: operator does not exist: timestamp with time zone - integer
Any ideas?
PostgreSQL can't use mathematical functions directly I think. But we can use date function such interval function in PostgreSQL will solve your problem.
Try below subtract eg:
select interval '2 day' - interval '1 day';
select now() - interval '1' ;
You can also refer to PostgreSQL 8.4 documentation.
http://www.postgresql.org/docs/8.4/static/functions-datetime.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.