1

According to CiviCRM user guide article's Searching section The Date Range Filter:

Relative date ranges are especially useful for searches that you would like to then save as Smart Groups (automatically populated groups that are configured to include contacts that share a certain set of characteristics or activities).

However, it seems that it is actually impossible to use them this way, because during search relative dates (e.g. Today) are transformed into fixed dates (e.g. August 18th).

See: How to use Smart Groups with relative dates? and smart group change log criteria

Is it a recent bug or has it been like this forever? Will there be a fix for that?

2

I think you may find that, although the search results show the relative dates converted to fixed dates, when you create a smart group from the results it will save the relative date range.

That is certainly what happens in my live v4.4.

I have also checked this as best I can on a 4.7.10 site that has had no activity or changes on it since February this year. I have a smart group based on a search that used the relative date filter Previous month. That group has no contacts now and if I go to Edit smart group search criteria... (via the Contacts link on the Manage Groups page) I see:

No matches found for: ...AND Activity Date - greater than or equal to "01 July 2016 12:00 AM" AND less than or equal to "31 July 2016 11:59 PM" ...AND.

but when I click on Edit smart group search criteria... for the second time it shows me the actual search parameters which include:

Activity date :Previous Calendar month

  • It does not update for me in v4.7.9, so I am trying to test that in Sandbox, but apparently the Smart groups are reset daily. How can I test that? Also, what does Smart Group show in v4.4? For instance, can you see there relative ranges like Today, Yesterday, Last month or does it show fixed dates that are automatically updated daily? – Aivars Aug 19 '16 at 6:38
  • 1
    It shows fixed dates that are automatically updated daily/monthly , but the actual search criteria is saved with a relative date, I have updated my answer to explain this in more detail. – JoAnne Aug 19 '16 at 13:00
  • Thank you very much for the detailed answer. I can clearly see that it works for you as it is expected. However, CiviCRM behaves very differently on my site. See STEP 4. EDIT SMART GROUP in my comment below. I just tested it on CiviCRM Drupal Sandbox and it behaves exactly the same. Namely, when you click Edit, you don't see the relative date there. I could not test it in CiviCRM Wordpress Sandbox - the system won't give me permission to see the contacts that I create. Is not that strange that relative dates would not work in 4.7.9 and 4.7.11, but do in 4.7.10? What do I do now? – Aivars Aug 20 '16 at 8:30
  • 1
    I am starting to think that relative date filters work in smart groups created prior to an upgrade to 4.7 ( or perhpas even 4.6), but smart groups created in 4.7 don't work with relative date filters. I am testing further. – JoAnne Aug 20 '16 at 8:46
  • 1
    @Aivars I have confirmed this as a bug for new groups in 4.7.10 and will create an issue for it. – JoAnne Aug 21 '16 at 23:50
1

Let me clarify the sequence and point to some strange behavior.

STEP 1. ADVANCED SEARCH

Open Advanced search and go straight to Activities (without changing anything else).

Choose Activity Type (=Phone Call), relative Activity Date (=Today), Activity Status (=Unreachable). Click Search.

Advanced search

STEP 2. CREATE SMART GROUP

I see Activity Date has been replaced from relative Yesterday to fixed August 18th.

I create a Smart group by Selecting all records and choosing the Action Group - create smart group.

Create Smart group

STEP 3. SMART GROUP PARAMETERS

Not much here, but note that Activity Date here is also listed as fixed - August 18th (not Yesterday).

I click the Save Smart Group button.

Smart group

STEP 4. EDIT SMART GROUP.

That is where all the fun begins.

First, if I do nothing, the Smart Group stays fixed to the particular date and never gets updated to new values.

Second, if I try to Edit the Smart Group, it shows entirely different search parameters.

  • Relative Activity date field is empty.
  • There is a fixed date value in Activity date field.
  • Activity status Unreachable has been changed to Completed and Scheduled.

Edit Smart group

SUMMARY.

  • The unexpected change of parameters in Edit mode has a very buggy feel.
  • Relative date values are transformed to fixed which do not get updated.
    • Scheduled Job - Rebuild Smart Group Cache (no parameters) does not help.
  • I can not test this on CiviCRM Sandbox, because database is being reset daily(?).
  • @JoAnne reports the Relative dates work in Smart groups in v4.4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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