title: Age Calculation Query
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/57599/how-to-calculate-age-in-t-sql-with-years-months-and-days">How to calculate age in T-SQL with years, months, and days</a><br>
    <a href="https://stackoverflow.com/questions/13161401/calculating-age-from-sysdate-and-birthdate-using-sql-server">calculating age from sysdate and birthdate using SQL Server</a>  </p>
  </blockquote>
  
  
  
  <p>In the process of some age calculations.  I'm a bit of a novice when it comes to SQL but I've been tasked with singling out persons who will turn <code>65yrs</code> old as of <code>31 March 2013</code>.  So far I'm able to calculate age based on given <code>DOB</code>, however I'm having issues singling out these persons.  I'm thinking this is a simple issue but I'm stumped, see sql statement.  Can someone please point me in the right direction.</p>
  
  <pre><code>SELECT ip_master.ssn, ip_master.firstname, ip_master.surname, ip_master.status,
  
  CASE WHEN DATEADD(YEAR, DATEDIFF (YEAR, dob, '2013/03/31'), dob) &gt; '2013/03/31'
  THEN DATEDIFF(YEAR, dob, '2013/03/31') - 1
  ELSE DATEDIFF(YEAR, dob, '2013/03/31')
  END AS 'Age'
  
  FROM test_db.dbo.ip_master ip_master
  </code></pre>