oracle数据库怎么判断某个时间在一段时间之内

oracle数据库怎么判断某个时间在一段时间之内,第1张

用to_char函数即可。

如emp表中数据如下:

要查询hiredate的日期为1981年1月1日到1981年5月1日之间的数据,可用如下语句:

select * from emp where to_char(hiredate,'yyyy-mm-dd') between '1981-01-01' and '1981-05-01'

查询结果:

某个时间:date

时间段1:date1~date2

时间段2:date3~date4

时间段3:date5~date6

case

when date between date1 and date2 then '时间段'1'

when date between date3 and date4 then '时间段'2'

when date between date5 and date6 then '时间段'3'

end '时间段'


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/9953307.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-03
下一篇2023-05-03

发表评论

登录后才能评论

评论列表(0条)

    保存