Answers.Body: <p>It will be possible from version 4.7.21 through the following improvements <a href="https://issues.civicrm.org/jira/browse/CRM-18081" rel="nofollow noreferrer">CRM-18081 - Allow search of active relationships during a custom range of dates</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-14T18:15:38.973Z
Answers.LastActivityDate: 2017-06-14T18:15:38.973Z
Answers.UserDisplayName: Francesc Bassas i Bullich
Answers.Body: <p>I would do the following, although it's a bit complicated so maybe you will want to develop a custom search after reading :).</p>
  
  <p>Create a smart group to keep track of your active volunteers by searching for relationship type 'volunteer for' and status = active only (no start or end dates so you grab those empty end date people).</p>
  
  <p>When you have your date criteria, for example the past year, create a group of folks who stopped volunteering in the past year by searching relationship type 'volunteer for', status = inactive only, and end date choose range choose your range, such as Jan 1, 2014 - Current date.</p>
  
  <p>Now to get folks who are still active, or ended in the past year, do an OR search (checkbox in advanced search) using your 'active' smart group and your 'inactive in the past year' group.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-08T12:49:07.717Z
Answers.Text: In 4.6.11 there is a new feature that can help to complement this workaround https://issues.civicrm.org/jira/browse/CRM-17727.
Answers.UserDisplayName: Francesc Bassas i Bullich
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-08T15:16:27.883Z
Answers.Text: Thanks! This will be helpful for me in the future as well.
Answers.UserDisplayName: Eli Lisseck
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-29T15:44:05.107Z
Answers.LastActivityDate: 2015-12-29T15:44:05.107Z
Answers.UserDisplayName: Eli Lisseck
Answers.Body: <p>Just stumbled across this old question, but Search Kit is now another option: see <a href="https://dmaster.demo.civicrm.org/civicrm/admin/search#/create/Contact?params=%7B%22version%22:4,%22select%22:%5B%22id%22,%22display_name%22,%22Contact_RelationshipCache_Contact_01.display_name%22%5D,%22orderBy%22:%7B%7D,%22where%22:%5B%5D,%22groupBy%22:%5B%5D,%22join%22:%5B%5B%22Contact%20AS%20Contact_RelationshipCache_Contact_01%22,%22INNER%22,%22RelationshipCache%22,%5B%22id%22,%22%3D%22,%22Contact_RelationshipCache_Contact_01.far_contact_id%22%5D,%5B%22Contact_RelationshipCache_Contact_01.near_relation:name%22,%22%3D%22,%22%5C%22Volunteer%20for%5C%22%22%5D,%5B%22OR%22,%5B%5B%22Contact_RelationshipCache_Contact_01.end_date%22,%22IS%20EMPTY%22%5D,%5B%22Contact_RelationshipCache_Contact_01.end_date%22,%22%3E%3D%22,%22%5C%22previous.year%5C%22%22%5D%5D%5D,%5B%22OR%22,%5B%5B%22Contact_RelationshipCache_Contact_01.start_date%22,%22IS%20EMPTY%22%5D,%5B%22Contact_RelationshipCache_Contact_01.start_date%22,%22%3C%3D%22,%22%5C%22previous.year%5C%22%22%5D%5D%5D%5D%5D,%22having%22:%5B%5D%7D" rel="nofollow noreferrer">here</a></p>
  <p><a href="https://i.sstatic.net/A2q4A.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/A2q4A.png" alt="enter image description here" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-05T11:16:33.890Z
Answers.Text: Yes SearchKit allows it but at the moment it is somewhat complicated. For example in your case you have not considered relationships that start and end dates are within the "previous calendar year". Ideally, it would be possible to include in SearchKit a filter at the relationship level as was done in the report and the advanced search with "Active period". See https://github.com/civicrm/civicrm-core/pull/10333/files
Answers.UserDisplayName: Francesc Bassas i Bullich
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-05T11:58:18.173Z
Answers.Text: I may be misunderstanding you, but it does cope with start and end dates within 'previous calendar year' - check the dmaster link.
Answers.UserDisplayName: Aidan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-05T12:38:12.040Z
Answers.Text: Sorry, you are absolutely right. I have rushed. In any case, I maintain the impression that it would help to minimize confusion to be able to build the search with a simple "relationship active period" = "previous calendar year"
Answers.UserDisplayName: Francesc Bassas i Bullich
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-05T14:53:29.057Z
Answers.Text: "relationship active period" = "previous calendar year" feature - yes!
Answers.UserDisplayName: Aidan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-05T17:30:45.127Z
Answers.Text: I opened a proposal to add new feature for SearchKit to handle a more generic "entity active period". See [SearchKit: Add ability to search and filter by active periods](https://lab.civicrm.org/dev/core/-/issues/3878)
Answers.UserDisplayName: Francesc Bassas i Bullich
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-05T09:18:24.627Z
Answers.LastActivityDate: 2022-05-05T09:18:24.627Z
Answers.UserDisplayName: Aidan
Answers.Body: <p>It seems there is no an easy way to get this information.</p>
  <p>Given a <strong>date range</strong> in which you want to find out the relationships that were active, the search should take into account up to four circumstances. Match all relationships where:</p>
  <hr />
  <p><strong>(A)</strong> Relationships with defined start and end dates</p>
  <blockquote>
  <p><em>Relationship start date</em> <strong>is before</strong> <em>date range end date</em></p>
  <p><strong>AND</strong></p>
  <p><em>Relationship end date</em> <strong>is after</strong> <em>date range start date</em></p>
  </blockquote>
  <p><a href="https://i.sstatic.net/0c8z2.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/0c8z2.png" alt="enter image description here" /></a></p>
  <p><strong>(B)</strong> Relationships with undefined end date</p>
  <blockquote>
  <p><em>Relationship start date</em> <strong>is before</strong> <em>date range end date</em></p>
  <p><strong>AND</strong></p>
  <p><em>Relationship end date</em> <strong>is empty</strong></p>
  </blockquote>
  <p><a href="https://i.sstatic.net/JdQ8d.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/JdQ8d.png" alt="enter image description here" /></a></p>
  <p><strong>(C)</strong> Relationships with undefined start date</p>
  <blockquote>
  <p><em>Relationship start date</em> <strong>is empty</strong></p>
  <p><strong>AND</strong></p>
  <p><em>Relationship end date</em> <strong>is after</strong> <em>date range end date</em></p>
  </blockquote>
  <p><a href="https://i.sstatic.net/htilZ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/htilZ.png" alt="enter image description here" /></a></p>
  <p><strong>(D)</strong> Relationships with undefined start and end dates</p>
  <blockquote>
  <p><em>Relationship start date</em> <strong>is empty</strong></p>
  <p><strong>AND</strong></p>
  <p><em>Relationship end date</em> <strong>is empty</strong></p>
  </blockquote>
  <p><a href="https://i.sstatic.net/4x9ue.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/4x9ue.png" alt="enter image description here" /></a></p>
  <hr />
  <p>Unfortunately, there is no &quot;is empty&quot; date range operator in the Advanced Search relationship form to cover this solution. If any, would create four smart groups nested to another group to satisfy the search in question.</p>
  <p>Instead, Relationship Contact Report does incorporate the empty operator in the filter report for start and end dates.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-22T10:49:35.573Z
Answers.Text: I opened these two related issues: [CRM-18080 Allow search for empty dates on relationships advanced search](https://issues.civicrm.org/jira/browse/CRM-18080) and [CRM-18081 Allow search of active/inactive relationships during a custom range of dates](https://issues.civicrm.org/jira/browse/CRM-18081)
Answers.UserDisplayName: Francesc Bassas i Bullich
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-22T20:11:13.220Z
Answers.Text: hmm. and Relationships isn't available via Search Builder by looks of it
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-21T18:45:33.773Z
Answers.LastActivityDate: 2016-02-21T18:45:33.773Z
Answers.LastEditDate: 2020-06-17T09:00:50.810Z
Answers.UserDisplayName: Francesc Bassas i Bullich
Answers.Body: <p>Do you have info about Memberships, Event participants and Activities completed by Contacts? All of those can be searched by date and Groups/Smart Groups created based on the action taken and the date completed. If a contact was a contributing Member, or made a Contribution otherwise, and/or attended an Event, and/or completed an Activity, like making phone calls or signing up other Members, that to me is an indication that someone is active, whether or not the person has a Relationship of type Volunteer or not. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-08T12:23:41.160Z
Answers.Text: Could be an option but we have volunteers on which only recorded how much time they are with us.
Answers.UserDisplayName: Francesc Bassas i Bullich
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-04T20:34:38.727Z
Answers.LastActivityDate: 2016-01-04T20:34:38.727Z
Answers.UserDisplayName: Joe McLaughlin
Body: <p>We record volunteer relationships for our Volunteer contacts.</p>
  
  <p>A contact is an active Volunteer of our organization if exists a relationship "volunteer for" and this relationship has no an "end date".</p>
  
  <p>In the same way, a contact is an inactive Volunteer of our organization if  exists a relationship "volunteer for" and this relationship has a past "start date" and a past "end date".</p>
  
  <p><strong>The difficulty is when you want to get a list of all the volunteers that were active during for example the past year.</strong></p>
  
  <p>How can I obtain a list of these contacts? There is no current built in search to achieve it? We must develop a customized search?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-15T08:28:32.493Z
Comments.Text: does doing a search for Relationship End date is greater than 1 Jan 2015 get you those who were active but ceased part way through year. Along with a second separate search for Start Date is before 1 Jan 2016 AND end date is empty get you close?
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-17T17:54:08.237Z
Comments.Text: I had already tried the following to search all the 2014 active relationships:
  
  Search all (active&inactive) relationships with Start Date before 1 2015 and End Date after 1 Jan 2014. But this option does not includes when the End Date is not yet defined and is empty. You can search with the built-in search if an End Date is empty?
Comments.UserDisplayName: Francesc Bassas i Bullich
Tags: <civireport><search><relationships><custom-search><searchkit>
Title: How to search active relationships (e.g) during past year?
ThreadText: # How to search active relationships (e.g) during past year?
  
  (Asked by: username_0 on 2015-12-14)
  
  We record volunteer relationships for our Volunteer contacts.
  
  A contact is an active Volunteer of our organization if exists a relationship "volunteer for" and this relationship has no an "end date".
  
  In the same way, a contact is an inactive Volunteer of our organization if exists a relationship "volunteer for" and this relationship has a past "start date" and a past "end date".
  
  **The difficulty is when you want to get a list of all the volunteers that were active during for example the past year.**
  
  How can I obtain a list of these contacts? There is no current built in search to achieve it? We must develop a customized search?
  
  **Tags:** civireport, search, relationships, custom-search, searchkit
  
  > **Comments:**
  > **username_1**: does doing a search for Relationship End date is greater than 1 Jan 2015 get you those who were active but ceased part way through year. Along with a second separate search for Start Date is before 1 Jan 2016 AND end date is empty get you close?  
  > **username_0**: I had already tried the following to search all the 2014 active relationships:  Search all (active&inactive) relationships with Start Date before 1 2015 and End Date after 1 Jan 2014. But this option does not includes when the End Date is not yet defined and is empty. You can search with the built-in search if an End Date is empty?  
  
  ---
  
  ## 5 answers
  
  ### Answer by username_0 on 2017-06-14. Score: 0 | Accepted answer
  
  It will be possible from version 4.7.21 through the following improvements [CRM-18081 - Allow search of active relationships during a custom range of dates](https://issues.civicrm.org/jira/browse/CRM-18081)
  
  
  ---
  
  ### Answer by username_2 on 2015-12-29. Score: 4
  
  I would do the following, although it's a bit complicated so maybe you will want to develop a custom search after reading :).
  
  Create a smart group to keep track of your active volunteers by searching for relationship type 'volunteer for' and status = active only (no start or end dates so you grab those empty end date people).
  
  When you have your date criteria, for example the past year, create a group of folks who stopped volunteering in the past year by searching relationship type 'volunteer for', status = inactive only, and end date choose range choose your range, such as Jan 1, 2014 - Current date.
  
  Now to get folks who are still active, or ended in the past year, do an OR search (checkbox in advanced search) using your 'active' smart group and your 'inactive in the past year' group.
  
  > **Comments:**
  > **username_0**: In 4.6.11 there is a new feature that can help to complement this workaround https://issues.civicrm.org/jira/browse/CRM-17727.  
  > **username_2**: Thanks! This will be helpful for me in the future as well.  
  
  ---
  
  ### Answer by username_3 on 2022-05-05. Score: 2
  
  Just stumbled across this old question, but Search Kit is now another option: see [here](https://dmaster.demo.civicrm.org/civicrm/admin/search#/create/Contact?params=%7B%22version%22:4,%22select%22:%5B%22id%22,%22display_name%22,%22Contact_RelationshipCache_Contact_01.display_name%22%5D,%22orderBy%22:%7B%7D,%22where%22:%5B%5D,%22groupBy%22:%5B%5D,%22join%22:%5B%5B%22Contact%20AS%20Contact_RelationshipCache_Contact_01%22,%22INNER%22,%22RelationshipCache%22,%5B%22id%22,%22%3D%22,%22Contact_RelationshipCache_Contact_01.far_contact_id%22%5D,%5B%22Contact_RelationshipCache_Contact_01.near_relation:name%22,%22%3D%22,%22%5C%22Volunteer%20for%5C%22%22%5D,%5B%22OR%22,%5B%5B%22Contact_RelationshipCache_Contact_01.end_date%22,%22IS%20EMPTY%22%5D,%5B%22Contact_RelationshipCache_Contact_01.end_date%22,%22%3E%3D%22,%22%5C%22previous.year%5C%22%22%5D%5D%5D,%5B%22OR%22,%5B%5B%22Contact_RelationshipCache_Contact_01.start_date%22,%22IS%20EMPTY%22%5D,%5B%22Contact_RelationshipCache_Contact_01.start_date%22,%22%3C%3D%22,%22%5C%22previous.year%5C%22%22%5D%5D%5D%5D%5D,%22having%22:%5B%5D%7D)
  
  [![enter image description here](https://i.sstatic.net/A2q4A.png)](https://i.sstatic.net/A2q4A.png)
  
  > **Comments:**
  > **username_0**: Yes SearchKit allows it but at the moment it is somewhat complicated. For example in your case you have not considered relationships that start and end dates are within the "previous calendar year". Ideally, it would be possible to include in SearchKit a filter at the relationship level as was done in the report and the advanced search with "Active period". See https://github.com/civicrm/civicrm-core/pull/10333/files  
  > **username_3**: I may be misunderstanding you, but it does cope with start and end dates within 'previous calendar year' - check the dmaster link.  
  > **username_0**: Sorry, you are absolutely right. I have rushed. In any case, I maintain the impression that it would help to minimize confusion to be able to build the search with a simple "relationship active period" = "previous calendar year"  
  > **username_3**: "relationship active period" = "previous calendar year" feature - yes!  
  > **username_0**: I opened a proposal to add new feature for SearchKit to handle a more generic "entity active period". See [SearchKit: Add ability to search and filter by active periods](https://lab.civicrm.org/dev/core/-/issues/3878)  
  
  ---
  
  ### Answer by username_0 on 2016-02-21. Score: 1
  
  It seems there is no an easy way to get this information.
  
  Given a **date range** in which you want to find out the relationships that were active, the search should take into account up to four circumstances. Match all relationships where:
  
  ---
  
  **(A)** Relationships with defined start and end dates
  
  > *Relationship start date* **is before** *date range end date*
  >
  > **AND**
  >
  > *Relationship end date* **is after** *date range start date*
  
  [![enter image description here](https://i.sstatic.net/0c8z2.png)](https://i.sstatic.net/0c8z2.png)
  
  **(B)** Relationships with undefined end date
  
  > *Relationship start date* **is before** *date range end date*
  >
  > **AND**
  >
  > *Relationship end date* **is empty**
  
  [![enter image description here](https://i.sstatic.net/JdQ8d.png)](https://i.sstatic.net/JdQ8d.png)
  
  **(C)** Relationships with undefined start date
  
  > *Relationship start date* **is empty**
  >
  > **AND**
  >
  > *Relationship end date* **is after** *date range end date*
  
  [![enter image description here](https://i.sstatic.net/htilZ.png)](https://i.sstatic.net/htilZ.png)
  
  **(D)** Relationships with undefined start and end dates
  
  > *Relationship start date* **is empty**
  >
  > **AND**
  >
  > *Relationship end date* **is empty**
  
  [![enter image description here](https://i.sstatic.net/4x9ue.png)](https://i.sstatic.net/4x9ue.png)
  
  ---
  
  Unfortunately, there is no "is empty" date range operator in the Advanced Search relationship form to cover this solution. If any, would create four smart groups nested to another group to satisfy the search in question.
  
  Instead, Relationship Contact Report does incorporate the empty operator in the filter report for start and end dates.
  
  > **Comments:**
  > **username_0**: I opened these two related issues: [CRM-18080 Allow search for empty dates on relationships advanced search](https://issues.civicrm.org/jira/browse/CRM-18080) and [CRM-18081 Allow search of active/inactive relationships during a custom range of dates](https://issues.civicrm.org/jira/browse/CRM-18081)  
  > **username_1**: hmm. and Relationships isn't available via Search Builder by looks of it  
  
  ---
  
  ### Answer by username_4 on 2016-01-04. Score: 1
  
  Do you have info about Memberships, Event participants and Activities completed by Contacts? All of those can be searched by date and Groups/Smart Groups created based on the action taken and the date completed. If a contact was a contributing Member, or made a Contribution otherwise, and/or attended an Event, and/or completed an Activity, like making phone calls or signing up other Members, that to me is an indication that someone is active, whether or not the person has a Relationship of type Volunteer or not.
  
  > **Comments:**
  > **username_0**: Could be an option but we have volunteers on which only recorded how much time they are with us.  
  
  ---
  
  