Calculate Age on The Fly
Calculate Age on The Fly
![rmattesich](https://secure.gravatar.com/avatar/47444158f064a6cf63a3f154f33d9618/?default=https%3A%2F%2Fvanillicon.com%2F47444158f064a6cf63a3f154f33d9618_200.png&rating=g&size=120)
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,
Rom
Punta Gorda, FL
Thanks a lot,
Rom
Punta Gorda, FL
This discussion has been closed.
Replies
[code]
mData: 'date', // property name
mRender: function (data, type, row) {
return prettyDate( data );
}
[/code]
where `prettyDate` is something like John Resig's date formatter: http://ejohn.org/blog/javascript-pretty-date/ .
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.
Allan