DBAsupport.com Forums - Powered by vBulletin
Results 1 to 10 of 13

Thread: Number of working Days (Mon-Fri) between two dates?

Threaded View

  1. #4
    Join Date
    Dec 2002
    Location
    Bangalore ( India )
    Posts
    2,434
    How about this one which will not read any rows..jus a calculation and i suppose will be fastest !!

    Code:
    Select 
      Dayz 
           -
      Nvl(Floor(Round((Dayz+Add_To_Dayz)/7,2)) * 2, 0)
      Week_Days
    From
      (
      Select 
        Trunc(End_Date) 
             - 
        Trunc(Start_Date) 
             - 
        Decode(Substr(To_Char(Start_Date, 'DAY'), 1, 3), 'SUN', 1,
                                                         'SAT', 2,
                                                                0
              ) 
             -
        Decode(Substr(To_Char(End_Date, 'DAY'), 1, 3), 'SUN', 2,
                                                       'SAT', 1,
                                                              0
              ) 
           +
        1
        Dayz, 
        Decode(Substr(To_Char(Start_Date, 'DAY'), 1, 3), 'MON', 1,
                                                         'TUE', 2,
                                                         'WED', 3,
                                                         'THU', 4,
                                                         'FRI', 5,
                                                                0
              ) Add_To_Dayz
      From
      Dual
      )
    ;
    PS : I have tested for few cases, not thoroughly tested...but seems ok to me.

    Abhay.
    Last edited by abhaysk; 02-04-2004 at 07:09 AM.
    funky...

    "I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."

    "Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width