oracle 中关于时间类型的计算是相当的简单的,
oracle 对时间类型的计算 对运算符进行的重载。
pg 里的时间的计算比oracle 要弱不少,目前只实现了 date 类型的 “+” 操作
例如:
1 | cyp_nw_app=> select current_date +7 ,current_date ; |
3 | ------------+------------ |
4 | 2012-04-27 | 2012-04-20 |
对于time ,timestamp 类型的加减操作,操作的因子是要 interval 类型的数据的
例如:
01 | cyp_nw_app=> select interval '7days' ; |
07 | cyp_nw_app=> select current_timestamp , current_timestamp + interval '7d'; |
09 | -------------------------------+------------------------------- |
10 | 2012-04-20 15:07:31.425797+08 | 2012-04-27 15:07:31.425797+08 |
13 | cyp_nw_app=> select current_timestamp , current_timestamp + interval '7Y'; |
15 | -------------------------------+------------------------------- |
16 | 2012-04-20 15:07:37.165961+08 | 2019-04-20 15:07:37.165961+08 |
19 | cyp_nw_app=> select current_timestamp , current_timestamp + interval '7m'; |
21 | -------------------------------+------------------------------- |
22 | 2012-04-20 15:07:46.186136+08 | 2012-04-20 15:14:46.186136+08 |
25 | cyp_nw_app=> select current_timestamp , current_timestamp + interval '7w'; |
27 | -------------------------------+------------------------------- |
28 | 2012-04-20 15:07:52.080267+08 | 2012-06-08 15:07:52.080267+08 |
31 | cyp_nw_app=> select current_timestamp , current_timestamp + interval '7s'; |
33 | -------------------------------+------------------------------- |
34 | 2012-04-20 15:07:56.222229+08 | 2012-04-20 15:08:03.222229+08 |
37 | cyp_nw_app=> select current_timestamp , current_timestamp + interval '7h'; |
39 | -------------------------------+------------------------------- |
40 | 2012-04-20 15:08:04.816308+08 | 2012-04-20 22:08:04.816308+08 |
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/133735/viewspace-721807/,如需转载,请注明出处,否则将追究法律责任。