title: Calculate business days in Oracle SQL(no functions or procedure)
body: <p>I am trying to calculate business days between two dates in Oracle select. I got to the point when my calculation gives most results correct for given dates (I compare it with NETWORKDAYS in excel) but sometimes it varies from 2 days to -2 days - and I don't know why... </p>
  
  <p>Here's my code:</p>
  
  <pre><code>SELECT
  ((to_char(CompleteDate,'J') - to_char(InstallDate,'J'))+1) - (((to_char(CompleteDate,'WW')+ (52 * ((to_char(CompleteDate,'YYYY') - to_char(InstallDate,'YYYY'))))) - to_char(InstallDate,'WW'))*2) as BusinessDays
  FROM TABLE
  </code></pre>
  
  <p>Thanks!</p>