Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2007
    Posts
    84

    Unanswered: DATEDIFF Function, Need to exlude Weekends

    Is there an Oracle function that I can use to find out the number of days between current date and another date? I would like to exclude Weekends and holidays, is this possible?

    Will DateDiff work or some other function within Oracle? Can anyone show me an example?

    Thank you.

    CC

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    In Oracle, you'd subtract two dates to get number of days between them.
    Code:
    SQL> select to_date('20.03.2007', 'dd.mm.yyyy') - -
    >           to_date('10.03.2007', 'dd.mm.yyyy') date_diff
      2  from dual;
    
     DATE_DIFF
    ----------
            10
    
    SQL>
    Excluding weekends? OK, could be done. But, excluding holidays? How does your Oracle version know which holidays are there in your country? It surely doesn't know my holidays. I guess you'll have to create your own function to do that.

  3. #3
    Join Date
    Feb 2007
    Posts
    84
    Yes I used this: TRUNC(CURRENT_DATE - datefield) AS NO_OF_DAYS. Now do you have an example of excluding the weekends? That is all I need now but in the future they want excluding holidays.

  4. #4
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

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