title: How to get numeric value of Months between two dates in PostgreSQL?
body: <p>I have two dates in format Time Stamp Without Time Zone.</p>
  
  <p>I want to compare them and get the numeric value of months between them:</p>
  
  <pre><code>select age(NOW(), '2012-03-24 14:44:55.454041+03')
  </code></pre>
  
  <p>Gives:</p>
  
  <pre><code>4 years 9 mons 2 days 21:00:27.165482
  </code></pre>
  
  <p>The trick here is that I need to convert this result into one value of months.</p>
  
  <p>So:
  In order to convert the <code>YEARS</code> to <code>Months</code>:</p>
  
  <pre><code>select EXTRACT(YEAR FROM age) * 12 + EXTRACT(MONTH FROM age) 
                  FROM age(NOW(), '2012-06-24 14:44:55.454041+03') AS t(age)
  </code></pre>
  
  <p>I get <code>57</code> which is <code>4*12+9</code>.</p>
  
  <p>My problem is that I don't know how to convert the days. 
  In the above example I need to convert the <code>'2 days'</code> into it's value in months.
  <code>'2 days'</code> isn't <code>0</code> months!</p>
  
  <p>In Months of 30 days 15 days are 0.5 months.</p>
  
  <p>How can I do that?
  The final result should be <code>57.something</code></p>