使用SQL获取当月第3个星期五的日期(不使用级别功能),也可以获得一个月内的工作日和所有月份的第3个星期五,谢谢
答案 0 :(得分:1)
您可以尝试以下代码。
SELECT NEXT_DAY(TO_DATE('JAN-2016','MON-YYYY')+13, 'FRIDAY') THIRD_FRIDAY FROM dual;
13:是否使用第3周(增加13天)
答案 1 :(得分:0)
这里有一些东西可以让你在2016年的所有月份的第三个星期五。但我不确定你为什么要避免使用connect by和level。
with months as (select to_date('01/01/2016', 'dd/mm/yyyy') start_of_month from dual union all
select to_date('01/02/2016', 'dd/mm/yyyy') start_of_month from dual union all
select to_date('01/03/2016', 'dd/mm/yyyy') start_of_month from dual union all
select to_date('01/04/2016', 'dd/mm/yyyy') start_of_month from dual union all
select to_date('01/05/2016', 'dd/mm/yyyy') start_of_month from dual union all
select to_date('01/06/2016', 'dd/mm/yyyy') start_of_month from dual union all
select to_date('01/07/2016', 'dd/mm/yyyy') start_of_month from dual union all
select to_date('01/08/2016', 'dd/mm/yyyy') start_of_month from dual union all
select to_date('01/09/2016', 'dd/mm/yyyy') start_of_month from dual union all
select to_date('01/10/2016', 'dd/mm/yyyy') start_of_month from dual union all
select to_date('01/11/2016', 'dd/mm/yyyy') start_of_month from dual union all
select to_date('01/12/2016', 'dd/mm/yyyy') start_of_month from dual)
select start_of_month,
next_day(start_of_month - 1, 'FRIDAY') + 14 third_friday_in_month
from months;
至于您要求获得一个月的工作日数,这取决于您的工作日"工作日"。你的意思是平日吗?或者工作日减去公众假期?还有别的吗?