开发者

PostgreSQL: Timestamp in the future

How can I get a timestamp with a date 30 days from now?

I tried things like now() + in开发者_Go百科teger '30'... but it didn't work.

I'm running Postgres 8.

Any ideas?


Try something like this:

SELECT NOW() + '30 days'::interval


The standard SQL expression is

select current_timestamp + interval '30' day

Quotes around the number, not around the phrase. See the earliest SQL standard I can find online, p 91. PostgreSQL is much more flexible than the standard, which can be a good thing or a bad thing. I support a lot of different dbms--the flexibility hurts me more often than it helps. PostgreSQL, for example, supports this non-standard statement.

select current_timestamp + interval '1 month, 2 days, 3 hours, 2 minutes';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜