2

I'm attempting to create a smart group that returns a list of people added on the current date without having to edit the criteria each day.

I've been starting with the "Date Added to CiviCRM" custom search, entering a date, then editing the civicrm_saved_search entry with no luck. Alternately, I'd settle for something that returns the last few people added using the maximum contact id number.

4

Unless I'm misunderstanding, you should be able to use Search menu > Advanced Search, select the "Change Log" accordion, and select the "Added" radio button. Then you can use relative date filters. I just tried it and it worked OK. I seem to recall that in Civi 4.3 and lower this was slow or broken, but should work in any modern version of Civi.

  • Perfect. I totally missed this because I limited my search options. For those who don't see "Change Log" in their advanced search, go to Administer > Customize Data and Screens > Display Preferences. Look for "Contact Search" and check "Change Log". – Eric H Sep 23 '15 at 16:19
2

You could copy the 'Date Added to CiviCRM' custom search and edit it. Had a quick go here and it seemed to work if you change $startDate and $endDate to just be the current day. So altering the block at line 181:

$startDate = date('Y-m-d');
$endDateFix = NULL;
if (!empty($this->_formValues['end_date'])) {
  $endDate = date('Y-m-d');
  # tack 11:59pm on to make search inclusive of the end date
  $endDateFix = "AND date_added <= '" . substr($endDate, 0, 10) . " 23:59:00'";
}

Not terribly elegant, but I think that works. You'd probably want to remove the date fields from the form too, just to avoid confusion.

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.