title: How to get age in years,months and days using Oracle
body: <p>I'm trying to print for each person its age using this format :</p>
  
  <p>E.g : 19 years , 8 months , 13 days.</p>
  
  <p>I've googled a lot and I've noticed that there is a specific function to calculate the difference between dates <code>DATEDIFF</code>.</p>
  
  <p>However this function does not exist in <code>SQL*Plus</code> , so I went on trying using <code>MONTHS_BETWEEN()</code> and some operators.</p>
  
  <p>My attempt:</p>
  
  <pre><code>SELECT name , ' ' || 
      FLOOR(MONTHS_BETWEEN(to_date(SYSDATE),to_date(date_of_birth))/12)||' years ' ||  
      FLOOR(MOD(MONTHS_BETWEEN(to_date(SYSDATE),to_date(date_of_birth)),12)) || ' months ' || 
      FLOOR(MOD(MOD(MONTHS_BETWEEN(to_date(SYSDATE),to_date(date_of_birth)),12),4))|| ' days ' AS "Age"
  FROM persons;
  </code></pre>
  
  <p>My issue relies on getting the days. I don't know how should I calculate the days , using this function ('tried dividing by 4 , or 30); I'm thinking my logic is bad but I can't figure it out , any ideas ?</p>