Number of fridays between two dates

前端 未结 7 1894
我寻月下人不归
我寻月下人不归 2020-12-06 06:58

How do I find the number of fridays between two dates(including both the dates) using a select statement in oracle sql?

7条回答
  •  自闭症患者
    2020-12-06 07:48

    I have to throw in my two cents for using a calendar table. (It's a compulsion.)

    select count(*) as num_fridays
    from calendar
    where day_of_week = 'Fri'
      and cal_date between '2011-01-01' and '2011-02-17';
    
    num_fridays
    -----------
    6
    

    Dead simple to understand. Takes advantage of indexes.

    Maybe I should start a 12-step group. Calendar Table Anonymous.

提交回复
热议问题