I'm storing birthdates in a Channel field.

  1. How do I display the birthdates as age in years? Is that something I just compute in the templates? Or is there a better way?
  2. I'm planning to use Low Search. Is there a way I will be able to filter something like "age is 25-30?"
  • How are you storing the date in your channel data. Are you using a text field, calendar field, or a third-party date field type? Dec 23, 2012 at 2:37
  • Text field. Is there a better option? I want users to just type in something like 1980/01/01. If there are better options, I'm open to them. Dec 23, 2012 at 2:39
  • 2
    You would definitely want to have it as either a native date field or a third-party date fieldtype so that you can easily pull the dates to calculate the age. Dec 23, 2012 at 2:50

1 Answer 1


Interesting question. Several options. For display, it should be possible to use a simple calculation plugin and subtract the birthday year from current year, current_time format="%Y"} (e.g. 2013 - 1980 == 33). For this to work you probably need the fieldtype to be of the "date" kind for date-formatting to work on the field.

For searching by date, you'll probably need to write a custom query, or use the active record plugin. Because the standard search:field="needle" parameter only works as string. A custom plugin that queries the database is also an option. Fetch the ID's that meet the criteria and feed those to the channel:entries tag entry_id="13|42|147"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.