oracle如何根据传入的时间参数,得到这个参数所在周的周一至周五的日期和星期数
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是取到当前日期的周一!