Search Age based on Date of Birth

Search Age based on Date of Birth

NavishaNavisha Posts: 2Questions: 1Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem: I have a column that displays date of birth (yyyy-mm-dd). Now I need to implement a search by age range. Is it possible to search an age(10, 15) based on date of birth? If yes, can you give me some ideas on how to do it. Thanks

Answers

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    You could create a custom filter for that. I don't have a specific example, but this example from this thread may get you going,

    Colin

  • NavishaNavisha Posts: 2Questions: 1Answers: 0
    edited April 2021

    Thanks for your reply Colin.

    I have tried the example above. It works if I have to search the age when it is already in a column. But as you can see in the sreenshot below, I have DOB in date format. Now I want to search max/min age based on the DOB. I know there is math involved. Do you have an idea how I can achieve this. Thanks

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    I know there is math involved.

    Yep, I agree with that :) You'll need to do that math I'm afraid to to get the boundaries that you want. That's more of a JS logic issue, rather than a DataTables issue though,

    Colin

This discussion has been closed.