oracle计算是否是同一周

函数已经解决跨年问题

select to_char(date'2016-12-31','iW') from dual;
select to_char(date'2017-01-01','iW') from dual;  
select to_char(date'2017-01-02','iW') from dual;


select trunc(date'2016-12-31', 'iw') from dual;
select trunc(date'2017-01-01', 'iw') from dual;
select trunc(date'2017-01-02', 'iw') from dual;

to_char(date,'w') 是本月第几周

还有个方法是取两个日期的下个周一,比较是否相同

next_day( sysdate, 'MONDAY') 

 

你可能感兴趣的:(oracle计算是否是同一周)