to_date() 时间相减
select to_date(untreat_date,'yyyy-mm-dd hh24:mi:ss')-to_date(reg_date,'yyyy-mm-dd hh24:mi:ss')
from XXX where to_date(untreat_date,'yyyy-mm-dd hh24:mi:ss')-to_date(reg_date,'yyyy-mm-dd hh24:mi:ss')>0
TRUNC(date[,fmt]) 截取
date 一个日期值
fmt 日期格式,该日期将由指定的元素格式所截去。忽略它则由最近的日期截去
trunc(sysdate,'yyyy') --返回当年第一天.
trunc(sysdate,'mm') --返回当月第一天.
trunc(sysdate,'d') --返回当前星期的第一天.
trunc(sysdate,'dd')--返回当前年月日
select status,count(*) countnum,CAST(sum(time) as decimal(38, 0))
sumtime from XXX where indate>trunc(sysdate-2)
AND indate<trunc(sysdate) group by status
本文介绍了如何使用to_date()函数进行时间相减以计算两个日期之间的差距,并展示了如何利用TRUNC函数来获取特定日期的截断值,此外还提供了一个统计不同状态记录下时间总和的示例。
6996

被折叠的 条评论
为什么被折叠?



