博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
pg 中日期型的计算问题
阅读量:2498 次
发布时间:2019-05-11

本文共 1972 字,大约阅读时间需要 6 分钟。

oracle 中关于时间类型的计算是相当的简单的,
oracle 对时间类型的计算 对运算符进行的重载。
pg 里的时间的计算比oracle 要弱不少,目前只实现了 date 类型的 “+” 操作
例如:
1 cyp_nw_app=> select current_date +7 ,current_date ;
2   ?column?  |    date   
3 ------------+------------
4  2012-04-27 | 2012-04-20
对于time ,timestamp 类型的加减操作,操作的因子是要 interval 类型的数据的
例如:
01 cyp_nw_app=>   select interval '7days' ;
02  interval
03 ----------
04  7 days
05  
06  
07 cyp_nw_app=> select current_timestamp , current_timestamp + interval '7d';
08               now              |           ?column?           
09 -------------------------------+-------------------------------
10  2012-04-20 15:07:31.425797+08 | 2012-04-27 15:07:31.425797+08
11 (1 DD????)
12  
13 cyp_nw_app=> select current_timestamp , current_timestamp + interval '7Y';
14               now              |           ?column?           
15 -------------------------------+-------------------------------
16  2012-04-20 15:07:37.165961+08 | 2019-04-20 15:07:37.165961+08
17 (1 DD????)
18  
19 cyp_nw_app=> select current_timestamp , current_timestamp + interval '7m';
20               now              |           ?column?           
21 -------------------------------+-------------------------------
22  2012-04-20 15:07:46.186136+08 | 2012-04-20 15:14:46.186136+08
23 (1 DD????)
24  
25 cyp_nw_app=> select current_timestamp , current_timestamp + interval '7w';
26               now              |           ?column?           
27 -------------------------------+-------------------------------
28  2012-04-20 15:07:52.080267+08 | 2012-06-08 15:07:52.080267+08
29 (1 DD????)
30  
31 cyp_nw_app=> select current_timestamp , current_timestamp + interval '7s';
32               now              |           ?column?           
33 -------------------------------+-------------------------------
34  2012-04-20 15:07:56.222229+08 | 2012-04-20 15:08:03.222229+08
35 (1 DD????)
36  
37 cyp_nw_app=> select current_timestamp , current_timestamp + interval '7h';
38               now              |           ?column?           
39 -------------------------------+-------------------------------
40  2012-04-20 15:08:04.816308+08 | 2012-04-20 22:08:04.816308+08
41 (1 DD????)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/133735/viewspace-721807/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/133735/viewspace-721807/

你可能感兴趣的文章
消息队列2
查看>>
C++ 线程同步之临界区CRITICAL_SECTION
查看>>
测试—自定义消息处理
查看>>
MFC中关于虚函数的一些问题
查看>>
根据图层名获取图层和图层序号
查看>>
规范性附录 属性值代码
查看>>
提取面狭长角
查看>>
Arcsde表空间自动增长
查看>>
Arcsde报ora-29861: 域索引标记为loading/failed/unusable错误
查看>>
记一次断电恢复ORA-01033错误
查看>>
C#修改JPG图片EXIF信息中的GPS信息
查看>>
从零开始的Docker ELK+Filebeat 6.4.0日志管理
查看>>
How it works(1) winston3源码阅读(A)
查看>>
How it works(2) autocannon源码阅读(A)
查看>>
How it works(3) Tilestrata源码阅读(A)
查看>>
How it works(12) Tileserver-GL源码阅读(A) 服务的初始化
查看>>
uni-app 全局变量的几种实现方式
查看>>
echarts 为例讲解 uni-app 如何引用 npm 第三方库
查看>>
uni-app跨页面、跨组件通讯
查看>>
springmvc-helloworld(idea)
查看>>