Calculate Age on The Fly

Calculate Age on The Fly

rmattesichrmattesich Posts: 2Questions: 0Answers: 0
edited March 2013 in Feature requests
Does anyone have some server or client code that takes Birthdate, in standard MySQL date format (yyyy-mm-dd) format, calculates, and displays Age as an integer using DataTable/Editor? (Or suggestion on how to do it efficiently?).
Thanks a lot,
Punta Gorda, FL


  • allanallan Posts: 55,108Questions: 1Answers: 8,653 Site admin
    edited March 2013
    You could use something like this:

    mData: 'date', // property name
    mRender: function (data, type, row) {
    return prettyDate( data );

    where `prettyDate` is something like John Resig's date formatter: .

    If you want age as an integer, a modification to that basic idea (calculate current date, calculate date object for data, extract difference and return years) would be possible.

This discussion has been closed.