• AIRWALKER-375999 (10/24/2016)


    Thom A (10/24/2016)


    If you are using your above logic, ensure you change your Current DOB logic as well. Otherwise, you'll notice that some other current ages will be wrong (such as 01-Nov-1987, which would show 29, not 28).

    Thanks for mentioning that, my final code is:

    select dob,

    floor(datediff(d,dob,getdate()) /365.25) as [current_age],

    floor(datediff(d,dob,dateadd(month,6,getdate())) /365.25) as [AGE_IN_SIX_MONTHS]

    from person

    These formulas aren't completely reliable.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2