Working Out Exact Age with DateDiff

  • Lynn Pettis (8/2/2012)


    Rob Schripsema (8/2/2012)


    Lynn Pettis (7/20/2009)


    Or

    WHERE

    ...

    and [CORE_CO-PERSON].[D-O-B] <= datediff(yy, -16, getdate()) -- where DOB is less than or equal to todays date 16 years ago.

    Now THAT is clever, elegant and easy to understand. Love it!

    But it should actually be dateadd, not datediff, right?

    You are correct. Took 3 years for someone to catch that mistake.

    Made an edit to my 3 year old post, but thought I should add the corrected code here as well:

    WHERE

    ...

    and [CORE_CO-PERSON].[D-O-B] <= dateadd(yy, -16, getdate()) -- where DOB is less than or equal to todays date 16 years ago.

  • Wow, Lynn. You are still following threads you participated in three years ago, and then really go back and correct them? That's what I call dedication 🙂

    --------------------------------------------------------------------------
    A little knowledge is a dangerous thing (Alexander Pope)
    In order for us to help you as efficiently as possible, please read this before posting (courtesy of Jeff Moden)[/url]

  • Jan Van der Eecken (8/2/2012)


    Wow, Lynn. You are still following threads you participated in three years ago, and then really go back and correct them? That's what I call dedication 🙂

    There are very few threads I have participated in that I have unsubscribed from, so yes, if someone posts to an old thread I'll see it. In this case, I felt it necessary to correct my old post putting the correct code closer where people will see it quickly instead of having to read down further.

Viewing 3 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic. Login to reply