trunc日期格式ww、iw、w的区别
ww | Same day of the week as the first day of the year | 按年度1月1日的第一天为每周第一天 |
iw | Same day of the week as the first day of the ISO week, which is Monday | 每周一 |
w | Same day of the week as the first day of the month | 按月份1日的第一天作为每周第一天 |
ww,按每年的1月1日为第一周第一天,1月8日为第二周第一天……依此类推
w,与ww功能类似,不过它是按每月的1日为每周第一天,例如1日为当月第一周第一天,8日为第二周第一天……依此类推。
也就是说,1月份的参数w与ww用trunc函数的结果应该是一致的。
2017-1-3为2017年第一周第三天,这周第一天为2017-1-1
select trunc(date'2017-1-3','w') from dual;
-------------------------
2017-1-1
2017-1-10为2017年第二周第三天,这周第一天为2017-1-8
select trunc(date'2017-1-10','w') from dual;
-------------------------
2017-1-8
iw,不受月份与年份的影响,直接取日期参数的周一。