title: Redshift datediff() vs. date_diff()
body: <p>It appears that Redshift supports two possible functions for computing a time interval distance between two <code>DATE</code>-like objects: <code>DATEDIFF()</code> &amp; <code>date_diff()</code>. The following code snippet provides an example of this behavior:</p>
  <pre><code>SELECT datediff(DAYS,   '2021-01-01'::DATE, '2021-02-01'::DATE) AS datediff_interval_output
       , datediff('day',  '2021-01-01'::DATE, '2021-02-01'::DATE) AS datediff_str_literal_output
       , date_diff('day', '2021-01-01'::DATE, '2021-02-01'::DATE) AS date_diff_output
  ;
  </code></pre>
  <p>AWS provides documentation on <a href="https://docs.aws.amazon.com/redshift/latest/dg/r_DATEDIFF_function.html" rel="nofollow noreferrer">DATEDIFF()</a>, however no record of <code>date_diff()</code> appears to exist within either Redshift or PostgreSQL documentation. A curious difference between the two functions is that <code>DATEDIFF</code> will accept either a raw interval for its first argument (e.g. <code>DAY</code>, <code>MONTH</code>, <code>SECOND</code>) or a string literal (<em>'day'</em>, <em>'month'</em>, <em>'second</em>'), but <code>date_diff()</code> only accepts string literal interval representations.</p>
  <p>The only reference I can find to <code>date_diff()</code> is an entry within <em>pg_catalog</em> which returns the following auto-generated definition:</p>
  <pre><code>CREATE FUNCTION date_diff(text, time with time zone, time with time zone) RETURNS bigint
      IMMUTABLE
      LANGUAGE internal AS
  $$
  begin
  -- missing source code
  end;
  $$;
  </code></pre>
  <p>Does anyone have additional insight around the origin of the <code>date_diff()</code> function, and why it's included on Redshift but is undocumented?</p>
  <hr />
  <p><sub><strong>Note:</strong> Using Redshift Version: 1.0.25109</sub></p>