title: How to get difference of days/months/years (datediff) between two dates?
body: <p>I am looking for a way to implement the <a href="https://docs.microsoft.com/en-us/sql/t-sql/functions/datediff-transact-sql?view=sql-server-2017" rel="noreferrer">SQLServer-function datediff</a> in PostgreSQL. That is, this function returns the count (as a signed integer value) of the specified datepart boundaries crossed between the specified start date and end date.</p>
  <pre><code>datediff(dd, '2010-04-01', '2012-03-05') = 704 // 704 changes of day in this interval
  datediff(mm, '2010-04-01', '2012-03-05') = 23  // 23 changes of month
  datediff(yy, '2010-04-01', '2012-03-05') = 2   // 2 changes of year
  </code></pre>
  <p>I know I could do 'dd' by simply using subtraction, but any idea about the other two?</p>