Home > Database > Mysql Tutorial > body text

PostgreSQL时间加减

PHPz
Release: 2018-09-30 14:26:06
forward
3498 people have browsed it

连夜声讨PG,竟然时间加减写法有坑

select CURRENT_TIMESTAMP::TIMESTAMP - '5 day'
Copy after login

以上向前减5天,一直报错:[Err] ERROR: invalid input syntax for type timestamp: “5 day”
折腾好久,网上也没有正确的说明。而改为+号就能正常执行

select CURRENT_TIMESTAMP::TIMESTAMP + '5 day'
Copy after login

很是奇葩,不得其姐。
无意间想到了INTERVAL关键字,加上就可以了。

select CURRENT_TIMESTAMP::TIMESTAMP + INTERVAL '5 day'select CURRENT_TIMESTAMP::TIMESTAMP - INTERVAL '5 day'
Copy after login

此处省略无数个问候!

更多相关教程请访问 MySQL视频教程

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template