sql server中的datepart()函数与mysql中的date_format()使用介绍
oracle相似用法
select to_char(TO_DATE('20110101', 'YYYYMMDD'), 'yyyyiw') as week, --oracle求当年的第几周
to_char(TO_DATE('20110101', 'YYYYMMDD'), 'yyyyww') as week2, --oracle求当年的第几周
to_char(TO_DATE('20110101', 'YYYYMMDD'), 'yyyy') as year, --oracle求第几年
to_char(TO_DATE('20110101', 'YYYYMMDD'), 'yyyymm') as month, --oracle求当年的第几月
to_char(TO_DATE('20110101', 'YYYYMMDD'), 'yyyyddd') as day, --oracle求当年的第几天
to_char(TO_DATE('20110401', 'YYYYMMDD'), 'yyyyq') as quarter -- oracle求当年的第几季度
from dual
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日的第一天作为每周第一天 |