如何获得某个日期是当月的第几个工作日?

[复制链接]
查看11 | 回复9 | 2014-2-19 11:55:14 | 显示全部楼层 |阅读模式
RT
回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
WW Week of year (1-53) where week 1 starts on the first day of the year and continues to the seventh day of the year.
W Week of month (1-5) where week 1 starts on the first day of the month and ends on the seventh.
IW Week of year (1-52 or 1-53) based on the ISO standard.
D Day of week (1-7).
DAY Name of day.
DD Day of month (1-31).
DDD Day of year (1-366).

不知道你想要什么结果?
回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
select to_char(sysdate,'DD') from dual
回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
最初由 gengyonghui 发布
[B]select to_char(sysdate,'DD') from dual [/B]

楼上的兄弟们,首先感谢回复
但是请看清楚问题,我问的是第几个工作日
回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
Select to_char(Sysdate,'d') -1 from dual;
--
SQL> Select '本周第'||(to_char(Sysdate,'d') -1)||'个工作日' from dual;
'本周第'||(TO_CHAR(SYSDATE,'D'
------------------------------------------------------
本周第5个工作日
----
SQL> Select '本周第'||(TO_char(to_date('20070301','yyyymmdd'),'d') -1)||'个工作日' From dual;
'本周第'||(TO_CHAR(TO_DATE('20
------------------------------
本周第4个工作日
但是周6它会显示第6个工作日
回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
20070301是2007年3月的第4个工作日?


不是问星期几。。。。
20070301明显是3月的第一个工作日。。。
20070305是的3个工作日
我问的是当月的第几个工作日?
回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
噢,看错了,等等再改改
回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
select sum(work_day)+1 Work_day_of_mon from
(select to_char(sysdate-to_char(sysdate,'DD')+level,'D'),
case to_char(sysdate-to_char(sysdate,'DD')+level,'D')
when '1' then 1
when '2' then 1
when '3' then 1
when '4' then 1
when '5' then 1
when '6' then 0
when '7' then 0
end as work_day from dual connect by level<to_char(sysdate,'DD'))


抛块苯砖先!


回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
select
sum( case
when to_char( (to_date(&输入时间,'yyyymmdd')- rownum+1),'day')='星期六' then 0
when to_char( (to_date(&输入时间,'yyyymmdd')- rownum+1),'day')='星期日' then 0
else 1 end)
num from dual
connect by rownum<=substr(&输入时间,7,2)
回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
哦,发晚了,可能跟楼上的意思差不多,
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行