Number of Weekends in a month

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vasuki Masilamani
    New Member
    • Dec 2006
    • 18

    Number of Weekends in a month

    Hi,
    Please help me getting the Oracle query which gives the number of Saturdays and Sundays for the current month. Thanks in advance.

    Thanks,
    Vasuki
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Kindly post what you have tried so far for further discussion on the topic.

    Kindly post your code.

    Comment

    • Vasuki Masilamani
      New Member
      • Dec 2006
      • 18

      #3
      To get the first saturday of a month

      select next_day(last_d ay(add_months(s ysdate,-1)),'Saturday') from dual

      I found that I can use some loop like rownum() etc.. to get it. But how to use the logic?

      Query to get all last saturdays of a year

      SELECT TO_CHAR (
      NEXT_DAY (
      LAST_DAY (
      ADD_MONTHS (TRUNC(SYSDATE, 'Y'),ROWNUM-1))-7,
      TO_CHAR (TO_DATE('29-01-1927', 'DD-MM-YYYY'),'DAY')
      ), 'DD.MM.YYYY') "Last Saturdays in 2004"
      FROM ALL_OBJECTS
      WHERE ROWNUM <= 12

      Similar query can be revamped to get my result..

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        Please find a related discussion here .

        Comment

        Working...