Answers.Body: <p>There is a way with the <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/CiviRules+Cookbook" rel="nofollow noreferrer">CiviRules</a> extension.  It's a similar concept as noted here: <a href="https://civicrm.stackexchange.com/a/4873/105">https://civicrm.stackexchange.com/a/4873/105</a></p>
  
  <p>Create two tags: Under 18 and 18+.</p>
  
  <p>Create two Rules:</p>
  
  <ol>
  <li>A generic <strong>trigger</strong> such as "Individual is changed" or "Individual is added".  CiviRules has a <strong>condition</strong> called "Age Comparison". You can set it to less than 18.  Then, for the <strong>action</strong>, 'add Tag to contact' using Under 18.</li>
  <li>Same trigger, Age Comparison condition - greater than or equal to 18.  But here have two actions: 'add Tag to contact 18+' as well as 'remove Tag from contact - Under 18' (to catch the people after they have turned 18).</li>
  </ol>
  
  <p>Create two smart group that looks for your respective tags. Any time a contact is updated in some way (if you go the 'Individual is changed' route), the Rules will fire and lead to updated smart groups.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T06:23:52.180Z
Answers.Text: I installed the extension and set it up as you described. I'm not getting any results. I set the trigger to individual changed, condition is age > 18 and action to tag contact with "18+". 
  To test, I edited a contact and saved but not result. I tried executing the civirules cronjob. Am I missing anything?
Answers.UserDisplayName: Yossi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T06:50:15.167Z
Answers.Text: OK. I see. It only adds the tag to the individual that was updated.
Answers.UserDisplayName: Yossi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T07:13:03.203Z
Answers.Text: Yes, the only 'catch' is that it can only go contact by contact. Depending on your comfort level with the API Explorer, you could update all contacts in some safe way and the rule would take effect on all of them.
Answers.UserDisplayName: Allen Hutchison
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T07:14:58.947Z
Answers.Text: Perhaps there is a field you're not using? Fill it in for all contacts via the API explorer and then use the API a second time to empty the field again. That would update the contacts and get you your groups once the smart groups update themselves (based on cron or manually firing the job).
Answers.UserDisplayName: Allen Hutchison
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T07:15:15.593Z
Answers.Text: So I was able to do it for a group of contacts using the trigger called :"Daily trigger for group members". When cron runs it updates everyone in a group
Answers.UserDisplayName: Yossi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T07:23:12.510Z
Answers.Text: Nice, that's a really good find!
Answers.UserDisplayName: Allen Hutchison
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-18T06:40:40.250Z
Answers.LastActivityDate: 2016-01-18T06:40:40.250Z
Answers.LastEditDate: 2017-04-13T12:53:13.017Z
Answers.UserDisplayName: Allen Hutchison
Answers.Body: <p>Although it doesn't help you right now, search by age will be in 4.7 - <a href="https://issues.civicrm.org/jira/browse/CRM-16160" rel="noreferrer">CRM-16160</a>.  You can try it in on the demo: <a href="http://dmaster.demo.civicrm.org/" rel="noreferrer">http://dmaster.demo.civicrm.org/</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-18T09:22:45.713Z
Answers.LastActivityDate: 2016-01-18T09:22:45.713Z
Answers.UserDisplayName: Aidan
Answers.Body: <p>This is now available in the UI (as noted by @Aidan above).</p>
  
  <p>To find it, use the <strong>Advanced Search</strong> and scroll down to <strong>Demographics</strong>:</p>
  
  <p><a href="https://i.sstatic.net/Z3lq5.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Z3lq5.jpg" alt="Search by age"></a></p>
  
  <p>Once you've configured your search you can save it as a <strong>Smart Group</strong> in the usual way to make the search results available very quickly and easily.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-21T18:25:30.023Z
Answers.LastActivityDate: 2019-10-21T18:25:30.023Z
Answers.UserDisplayName: Laryn
Answers.Body: <p>Not doable via UI afaik, and I don't recall anyone adding a custom search for this but there was a wiki page about that once upon a time - ah <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Upcoming+Birthday+and+Anniversary+searches" rel="nofollow">here</a> which may give you or someone else a head start - though it may need updating of course.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-18T05:39:26.763Z
Answers.LastActivityDate: 2016-01-18T05:39:26.763Z
Answers.UserDisplayName: petednz - fuzion
Body: <p>I would like to create 2 smart groups. 1 for members under 18 and one for members over 18. There is no search criteria for age rather only a static date.
  Any idea?</p>
  
Tags: <search>
Title: Contacts age as a search criteria/smart group?
ThreadText: # Contacts age as a search criteria/smart group?
  
  (Asked by: username_0 on 2016-01-18)
  
  I would like to create 2 smart groups. 1 for members under 18 and one for members over 18. There is no search criteria for age rather only a static date.
  Any idea?
  
  **Tags:** search
  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_1 on 2016-01-18. Score: 2 | Accepted answer
  
  There is a way with the [CiviRules](http://wiki.civicrm.org/confluence/display/CRMDOC/CiviRules+Cookbook) extension. It's a similar concept as noted here: <https://civicrm.stackexchange.com/a/4873/105>
  
  Create two tags: Under 18 and 18+.
  
  Create two Rules:
  
  1. A generic **trigger** such as "Individual is changed" or "Individual is added". CiviRules has a **condition** called "Age Comparison". You can set it to less than 18. Then, for the **action**, 'add Tag to contact' using Under 18.
  2. Same trigger, Age Comparison condition - greater than or equal to 18. But here have two actions: 'add Tag to contact 18+' as well as 'remove Tag from contact - Under 18' (to catch the people after they have turned 18).
  
  Create two smart group that looks for your respective tags. Any time a contact is updated in some way (if you go the 'Individual is changed' route), the Rules will fire and lead to updated smart groups.
  
  > **Comments:**
  > **username_0**: I installed the extension and set it up as you described. I'm not getting any results. I set the trigger to individual changed, condition is age > 18 and action to tag contact with "18+".  To test, I edited a contact and saved but not result. I tried executing the civirules cronjob. Am I missing anything?  
  > **username_0**: OK. I see. It only adds the tag to the individual that was updated.  
  > **username_1**: Yes, the only 'catch' is that it can only go contact by contact. Depending on your comfort level with the API Explorer, you could update all contacts in some safe way and the rule would take effect on all of them.  
  > **username_1**: Perhaps there is a field you're not using? Fill it in for all contacts via the API explorer and then use the API a second time to empty the field again. That would update the contacts and get you your groups once the smart groups update themselves (based on cron or manually firing the job).  
  > **username_0**: So I was able to do it for a group of contacts using the trigger called :"Daily trigger for group members". When cron runs it updates everyone in a group  
  > **username_1**: Nice, that's a really good find!  
  
  ---
  
  ### Answer by username_2 on 2016-01-18. Score: 5
  
  Although it doesn't help you right now, search by age will be in 4.7 - [CRM-16160](https://issues.civicrm.org/jira/browse/CRM-16160). You can try it in on the demo: <http://dmaster.demo.civicrm.org/>
  
  
  ---
  
  ### Answer by username_3 on 2019-10-21. Score: 1
  
  This is now available in the UI (as noted by @username_2 above).
  
  To find it, use the **Advanced Search** and scroll down to **Demographics**:
  
  [![Search by age](https://i.sstatic.net/Z3lq5.jpg)](https://i.sstatic.net/Z3lq5.jpg)
  
  Once you've configured your search you can save it as a **Smart Group** in the usual way to make the search results available very quickly and easily.
  
  
  ---
  
  ### Answer by username_4 on 2016-01-18. Score: 0
  
  Not doable via UI afaik, and I don't recall anyone adding a custom search for this but there was a wiki page about that once upon a time - ah [here](http://wiki.civicrm.org/confluence/display/CRMDOC/Upcoming+Birthday+and+Anniversary+searches) which may give you or someone else a head start - though it may need updating of course.
  
  
  ---
  
  