Friday, 29 March 2013

To find the weekend

/* Formatted on 3/29/2013 4:16:11 PM (QP5 v5.114.809.3010) */
SELECT   ROUND( (NEXT_DAY (TO_DATE (:binddate, 'DD-MON-YYYY') - 1,
                           'SATURDAY')
                 - NEXT_DAY (
                      TO_DATE (
                         '01-JAN-'
                         || EXTRACT (
                               YEAR FROM TO_DATE (:binddate, 'DD-MON-YYYY')
                            ),
                         'DD-MON-YYYY'
                      )
                      - 7,
                      'SUNDAY'
                   ))
               / 7)
            week_number
  FROM   DUAL




/* Formatted on 3/29/2013 4:16:19 PM (QP5 v5.114.809.3010) */
SELECT   NEXT_DAY (TO_DATE (:binddate, 'DD-MON-YYYY') - 1, 'SATURDAY')
  FROM   DUAL





/* Formatted on 3/29/2013 4:16:25 PM (QP5 v5.114.809.3010) */
SELECT   NEXT_DAY (TO_DATE (:binddate, 'DD-MON-YYYY') - 1, 'SATURDAY')
         - NEXT_DAY (
              TO_DATE (
                 '01-JAN-'
                 || EXTRACT (YEAR FROM TO_DATE (:binddate, 'DD-MON-YYYY')),
                 'DD-MON-YYYY'
              )
              - 7,
              'SUNDAY'
           )
  FROM   DUAL

No comments:

Post a Comment