Answers.Body: <p>After a small patch to CiviRules <a href="https://github.com/CiviCooP/org.civicoop.civirules/pull/70" rel="nofollow">PR 70</a> the solution is to go route 2, but simply use "-2 weeks". In fact any string recognized by strtotime can be used.</p>
  
  <ul>
  <li><strong>Trigger:</strong> Daily trigger for group members</li>
  <li><strong>Condition:</strong> Field value comparision : created_date &lt;= -2 weeks</li>
  <li><strong>Action:</strong> desired action, remove from Group</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-15T19:48:05.853Z
Answers.Text: The PR is merged
Answers.UserDisplayName: Jaap Jansma - CiviCooP
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-15T19:42:33.683Z
Answers.LastActivityDate: 2016-05-15T19:42:33.683Z
Answers.UserDisplayName: Alain Schaefer
Answers.Body: <p>You may be able to achieve this already out of the box.</p>
  
  <p>Create a rule like this:</p>
  
  <ul>
  <li><strong>Trigger:</strong> Contact added to group.</li>
  <li><strong>Condition:</strong> Contact is in group "the one you want"</li>
  <li><strong>Action:</strong> the desired action, with 14 days delay. Then check the box for rechecking of conditions. (You may also want to have an action of removing contact from the original group, so that the condition is no longer met, somewhere down the line...)</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-15T15:12:58.617Z
Answers.Text: Thanks for this hint! I already tought about this, but only now realize the beauty of this solution. Because in fact I will also send reminders after 7 and after 28 days. It makes everything very simple as all these are in one single rule! But ...... 1. the group is a smart-group, do smart groups also trigger "Contact added to group" ? 2. I also tried trigger "Contact created" which would be fine in this use case, but the contacts are created by an extension trough the civicrm API. It seems CiviCRM API does not trigger contact created. Is this only done in UI?
Answers.UserDisplayName: Alain Schaefer
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-15T16:14:39.750Z
Answers.Text: @AlainSchaefer Smart groups and CiviRules are generally not such a good match... But why not use a regular group, or even a tag. (I prefer tag, as it is easier to handle). Just test this real time, by choosing 7 and 28 minutes, instead of days:-)
Answers.UserDisplayName: Flying
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-15T16:21:34.420Z
Answers.Text: It may be very complicated, but you could have several Rules to achieve this. One could be with the trigger daily trigger of groups, and then add a tag (if not yet present). This could also apply for smart groups. Then you can follow up with a Rule with tag created, and 7 days delay as already explained. But of course, the more complicated the whole set-up is, the better it is to create a custom condition as @ErikH suggested
Answers.UserDisplayName: Flying
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-15T16:44:51.760Z
Answers.Text: thanks for the hint with the minutes, this will definitively help! Actually I just found that my problem is almost solved in [#58](https://github.com/CiviCooP/org.civicoop.civirules/issues/58). Just need to discover how to get this to work with timestamps as the field created_date is a timestamp.
Answers.UserDisplayName: Alain Schaefer
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-14T18:12:06.393Z
Answers.LastActivityDate: 2016-05-14T18:12:06.393Z
Answers.UserDisplayName: Flying
Answers.Body: <p>great to hear you are using CiviRules! Would be nice if you could take route 3 and do a PR so your action can be shared with other users too?</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-15T15:36:13.137Z
Answers.Text: Good suggestion, will definitvely consider this. Btw, I am already preparing a small PR for the emailapi extension.
Answers.UserDisplayName: Alain Schaefer
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-14T12:13:06.620Z
Answers.LastActivityDate: 2016-05-14T12:13:06.620Z
Answers.UserDisplayName: ErikH - CiviCooP
Body: <p>I am using Civicoops Rules extension. In our boarding process I need to create a rule to create actions for contacts which are still in a certain group after 14 days. My idea was to use the daily trigger for groups and add a condition for the field created_date. How can I do this?</p>
  
  <ul>
  <li>Should I use SQL as the compare value e.g. DATE_ADD(CURRENT_TIMESTAMP, INTERVAL 14 day)</li>
  <li>Should I use PHP as the compare value e.g. strtotime('-14 days');</li>
  <li>Should I create a custom condition as explained <a href="https://wiki.civicrm.org/confluence/display/CRMDOC/How+to+Create+Your+Own+Condition" rel="nofollow">here</a></li>
  </ul>
  
Tags: <civirules>
Title: CiviCRM Rules - Condition for contacts created X days ago
ThreadText: # CiviCRM Rules - Condition for contacts created X days ago
  
  (Asked by: username_0 on 2016-05-14)
  
  I am using Civicoops Rules extension. In our boarding process I need to create a rule to create actions for contacts which are still in a certain group after 14 days. My idea was to use the daily trigger for groups and add a condition for the field created\_date. How can I do this?
  
  * Should I use SQL as the compare value e.g. DATE\_ADD(CURRENT\_TIMESTAMP, INTERVAL 14 day)
  * Should I use PHP as the compare value e.g. strtotime('-14 days');
  * Should I create a custom condition as explained [here](https://wiki.civicrm.org/confluence/display/CRMDOC/How+to+Create+Your+Own+Condition)
  
  **Tags:** civirules
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2016-05-15. Score: 1 | Accepted answer
  
  After a small patch to CiviRules [PR 70](https://github.com/username_1/org.username_1.civirules/pull/70) the solution is to go route 2, but simply use "-2 weeks". In fact any string recognized by strtotime can be used.
  
  * **Trigger:** Daily trigger for group members
  * **Condition:** Field value comparision : created\_date <= -2 weeks
  * **Action:** desired action, remove from Group
  
  > **Comments:**
  > **username_1**: The PR is merged  
  
  ---
  
  ### Answer by username_2 on 2016-05-14. Score: 3
  
  You may be able to achieve this already out of the box.
  
  Create a rule like this:
  
  * **Trigger:** Contact added to group.
  * **Condition:** Contact is in group "the one you want"
  * **Action:** the desired action, with 14 days delay. Then check the box for rechecking of conditions. (You may also want to have an action of removing contact from the original group, so that the condition is no longer met, somewhere down the line...)
  
  > **Comments:**
  > **username_0**: Thanks for this hint! I already tought about this, but only now realize the beauty of this solution. Because in fact I will also send reminders after 7 and after 28 days. It makes everything very simple as all these are in one single rule! But ...... 1. the group is a smart-group, do smart groups also trigger "Contact added to group" ? 2. I also tried trigger "Contact created" which would be fine in this use case, but the contacts are created by an extension trough the civicrm API. It seems CiviCRM API does not trigger contact created. Is this only done in UI?  
  > **username_2**: @username_0 Smart groups and CiviRules are generally not such a good match... But why not use a regular group, or even a tag. (I prefer tag, as it is easier to handle). Just test this real time, by choosing 7 and 28 minutes, instead of days:-)  
  > **username_2**: It may be very complicated, but you could have several Rules to achieve this. One could be with the trigger daily trigger of groups, and then add a tag (if not yet present). This could also apply for smart groups. Then you can follow up with a Rule with tag created, and 7 days delay as already explained. But of course, the more complicated the whole set-up is, the better it is to create a custom condition as @username_3 suggested  
  > **username_0**: thanks for the hint with the minutes, this will definitively help! Actually I just found that my problem is almost solved in [#58](https://github.com/username_1/org.username_1.civirules/issues/58). Just need to discover how to get this to work with timestamps as the field created_date is a timestamp.  
  
  ---
  
  ### Answer by username_3 on 2016-05-14. Score: 2
  
  great to hear you are using CiviRules! Would be nice if you could take route 3 and do a PR so your action can be shared with other users too?
  
  > **Comments:**
  > **username_0**: Good suggestion, will definitvely consider this. Btw, I am already preparing a small PR for the emailapi extension.  
  
  ---
  
  