title: Counting Business Days PostgresSQL
body: <p>I am attempting to do something like this:</p>
  <pre><code>SELECT t.id, t.startdate, t.enddate, FOO
  FROM table
  </code></pre>
  <p>Where &quot;Foo&quot; is some sql mumbo-jumbo to calculate the business days between startdate and enddate like such:</p>
  <pre><code>+----+------------+------------+--------------+
  | id | startdate  |  enddate   | businessdays |
  +----+------------+------------+--------------+
  | 1  | 2020-09-12 | 2020-09-28 |     11       | 
  | 2  | 2020-09-02 | 2020-09-28 |     19       | 
  | 3  | 2020-09-22 | 2020-09-28 |     5        | 
  +----+------------+------------+--------------+
  </code></pre>
  <p>I was able to create a function to do so with no trouble:</p>
  <pre><code>CREATE OR REPLACE FUNCTION getbusinessday(startdate date, enddate date DEFAULT current_date) RETURNS int
  LANGUAGE plpgsql
  AS
  $$
  DECLARE
      daycount integer;
  BEGIN
      SELECT COUNT(i) 
      INTO daycount
      FROM generate_series(startdate,enddate,'1 day') i 
      WHERE EXTRACT(DOW FROM i) NOT IN (0, 6);
      RETURN daycount;
  END;
  $$;
  </code></pre>
  <p>Is there anyway I can achieve this without having to use this function?</p>
  <p>Bonus Question for Bonus Points:</p>
  <p>Would it be possible to allow for a timestamp to be entered and just have it cast to date within the actual function? I'm just curious.</p>