sql age function




If you are after accurate way to calculate Age using T-SQL then the below post might help you.

Below are questions that I try to answer in this post:

  • How to get age from birth date using getdate() (current date) in Tsql
  • How to calculate age from date of birth (DOB) and specified date
  • How to create T-SQL aging UDF function to calculate age from DOB and today's date or specified date
  • Calculate person's age (Accurate age calculation)

    T-SQL Age - years difference

    The above example show difference in years so it is not accurate. If you need accuracy than please use the code below.

Are you a paid member?

Log in or Buy Membership
Unlimited use access passes from $9
and long term discounts up to 87%





Did you find this page useful? +6  |  -0
(6 Votes)

I se a similar concept when checking lease expiry or doing period banding. Period with Fields like FinanceYear and FinanceMonth by if (CurrentFY*12+CurrentFM)-SoldFY*12+SoldFM)>12 -- then collect rent
Precise Explanation to why the approach was needed. Solid working example