Body: <p>What's the best way to calculate the total number of years/days that a contact has been a member?</p>
  
  <p>For example, say I want to find people who have been a member for more than 10 years, taking gaps into consideration.</p>
  
  <p>I was thinking of a combination of the "civicrm_log_membership" table with a custom field, or maybe the <a href="https://civicrm.org/extensions/summary-fields" rel="nofollow noreferrer">summary-fields</a> extension. By having it in a custom field, it would be easy to expose to the search/reports, and it could be regularly updated using a Scheduled Job.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-28T00:11:27.133Z
Comments.Text: i like the sound of Summary Fields approach
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-28T01:32:10.783Z
Comments.Text: In this case are you assuming if there is a gap this means there is a new membership? So this would be the sum of the duration of each membership on a contact that doesn't overlap?
Comments.UserDisplayName: Luke Stewart
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-01-28T18:56:23.437Z
Comments.Text: I always assumed that a gap would create a new membership, but a colleague insists that this is not always the case. I need to double-check (I would consider it a bug!).
Comments.UserDisplayName: bgm
Tags: <civimember>
Title: How to find members who have more than X years of total membership
ThreadText: # How to find members who have more than X years of total membership
  
  (Asked by: username_0 on 2020-01-27)
  
  What's the best way to calculate the total number of years/days that a contact has been a member?
  
  For example, say I want to find people who have been a member for more than 10 years, taking gaps into consideration.
  
  I was thinking of a combination of the "civicrm\_log\_membership" table with a custom field, or maybe the [summary-fields](https://civicrm.org/extensions/summary-fields) extension. By having it in a custom field, it would be easy to expose to the search/reports, and it could be regularly updated using a Scheduled Job.
  
  **Tags:** civimember
  
  > **Comments:**
  > **username_1**: i like the sound of Summary Fields approach  
  > **username_2**: In this case are you assuming if there is a gap this means there is a new membership? So this would be the sum of the duration of each membership on a contact that doesn't overlap?  
  > **username_0**: I always assumed that a gap would create a new membership, but a colleague insists that this is not always the case. I need to double-check (I would consider it a bug!).  
  
  ---
  
  ## 0 answers
  
  