PostgreSQL的日期运算计算函数使用
一:各个数据中的连接符 SqlServer的连接符:+(加号) Sqlite的连接符:.(点) PostgreSQL的连接符:||(或) 二: 今天在PostgreSQL计算日期的时候,翻了一些资料,很少,就记录下来吧~! 其中使用到的函数及变量 to_char()、Date()、now()、current_date 计算两个日期的差 current_date为今天的日期,为:2015-06-03 Date('2015-06-05')-current_date=2 select to_char(current_date,'yyyy')||'-'||to_char(birthday,'mm-dd'),Date(to_char(current_date,'mm-dd'))-current_date from tablename where delflag=0 and status=0 and Date(to_char(current_date,'mm-dd'))-current_date>=0 and Date(to_char(current_date,'mm-dd'))-current_date<=7 order by birthday desc 三: select now() + interval '1 days'; 1 month1 years'; 四: SqlServer中进行日期计算时,用到函数
CONVERT(),DATEPART(),getDate()
select CONVERT(varchar(10),CONVERT(varchar(4),DATEPART(year,getDate()))+'-'+ CONVERT(varchar(2),DATEPART(month,birthday))+'-'+CONVERT(varchar(2),DATEPART(day,birthday)),120),datediff(day,CONVERT(varchar(10),getdate(),120))
from tablename where delflag=0 and status=0
and datediff(day,120))<=7
and datediff(day,120))>=0 order by birthday desc (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- .net – 根据所选的单选按钮显示控件
- Ruby 1.9.3和Ruby 1.8.7之间的日期字符串解析的差
- 0617 关于 fastjson报ArrayIndexOutOfBoundsExce
- 正则表达式findall start()和end()?Python
- 深入分析:Flash VS HTML5到底谁统江山
- convetToWorldSpace,convetToNodeSpace等坐标变换
- 有没有办法检查宏如何在C或Objective-C中“扩展”
- 有没有办法在Xcode中显示iPhone调试器控制台的颜
- 扩展Selenium对于Flash(Flex)元素识别和操作的
- ios – Xcode 4 – 一键构建到多个设备?