How to get Age from any Date?

 Posted by vishalneeraj-24503 on 11/3/2014 | Category: Sql Server Interview questions | Views: 1607 | Points: 40
Answer:

We ahve to write below query:-
DECLARE @DATE_OF_BIRTH AS DATETIME = '2000-07-14';

SELECT (FLOOR(DATEDIFF(DAY,@DATE_OF_BIRTH,GETDATE()) / 365.25)) Age;

Output:-14
We have to divide whole Day by 365.25
Here,July has been passed so output will be 14.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response