码迷,mamicode.com
首页 > 数据库 > 详细

oracle如何根据传入的时间参数,得到这个参数所在周的周一至周五的日期和星期数

时间:2020-06-08 19:29:17      阅读:88      评论:0      收藏:0      [点我收藏+]

标签:函数   参数   rac   from   自己   har   核心   dual   run   

select ‘1‘ AS XQBH,to_char(trunc(to_date(‘2020-06-28‘ ,‘yyyy-mm-dd‘),‘iw‘),‘yyyy-mm-dd‘) AS RQ,‘星期一‘ as XQ
from dual
UNION ALL
select ‘2‘ AS XQBH,to_char(trunc(to_date(‘2020-06-30‘ ,‘yyyy-mm-dd‘),‘iw‘)+1,‘yyyy-mm-dd‘) AS RQ,‘星期二‘ as
XQ from dual
UNION ALL
select ‘3‘ AS XQBH,to_char(trunc(to_date(‘2020-06-28‘ ,‘yyyy-mm-dd‘),‘iw‘)+2,‘yyyy-mm-dd‘) AS RQ,‘星期三‘ as
XQ from dual
UNION ALL
select ‘4‘ AS XQBH,to_char(trunc(to_date(‘2020-06-30‘ ,‘yyyy-mm-dd‘),‘iw‘)+3,‘yyyy-mm-dd‘) AS RQ,‘星期四‘ as
XQ from dual
select ‘5‘ AS XQBH,to_char(trunc(to_date(‘2020-06-30‘ ,‘yyyy-mm-dd‘),‘iw‘)+1,‘yyyy-mm-dd‘) AS RQ,‘星期五‘ as
XQ from dual
UNION ALL
select ‘6‘ AS XQBH,to_char(trunc(to_date(‘2020-06-28‘ ,‘yyyy-mm-dd‘),‘iw‘)+2,‘yyyy-mm-dd‘) AS RQ,‘星期六‘ as
XQ from dual
UNION ALL
select ‘7‘ AS XQBH,to_char(trunc(to_date(‘2020-06-30‘ ,‘yyyy-mm-dd‘),‘iw‘)+3,‘yyyy-mm-dd‘) AS RQ,‘星期日‘ as
XQ from dual

 

如果其他参数,把上面的“2020-06-30”修改成自己的入参数就好,核心函数是trunc(sysydate,‘iw‘);iw是取到当前日期的周一!

oracle如何根据传入的时间参数,得到这个参数所在周的周一至周五的日期和星期数

标签:函数   参数   rac   from   自己   har   核心   dual   run   

原文地址:https://www.cnblogs.com/lzz1997/p/13067402.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!