Clarity

Expand all | Collapse all

Calculated Attribute DateDiff Function

  • 1.  Calculated Attribute DateDiff Function

    Posted 11-16-2018 05:49 PM

    Anyone have any experience or expertise using the DateDiff Function and how to exclude non-workdays (Saturday & Sunday)

     

    I am using the below function, but that only works if it is always divisible by 7 and assuming the start date begins on a Sunday and ends on a Saturday.

     

    ((DateDiff(start_date,end_date,""))-((DateDiff(start_date,end_date,"")/7)*2)+1)



  • 2.  Re: Calculated Attribute DateDiff Function

    Posted 11-20-2018 09:42 PM

    My suggestion:

    select inv.code, inv.schedule_start, inv.schedule_finish,
    (SELECT COUNT(*) FROM DUAL WHERE TO_CHAR(trunc(inv.schedule_start) + LEVEL - 1, 'DY') NOT IN ('SAT', 'SUN') CONNECT BY LEVEL <= trunc(inv.schedule_finish) - trunc(inv.schedule_start) + 1   )  Weekday_Count
      from inv_investments inv

    Above is for Oracle.