Answers.Body: <p>In 4.6.12 CRM/Contact/BAO/Query.php I've added this case in convertFormValues() to fix this - someone may do it more beautifully:</p>
  
  <pre><code>elseif (!empty($values) &amp;&amp; is_array($values) &amp;&amp; self::isCustomDateField($id)) {
      $from = FALSE;
      if (array_key_exists('from',$values)){
          $from = $values['from'];
          $from = CRM_Utils_Date::processDate($from);
      }
      $to = FALSE;
      if (array_key_exists('to',$values)){
          $to = $values['to'];
          $to = CRM_Utils_Date::processDate($to);
      }
      if( $from &amp;&amp; $to){
          $q = array('BETWEEN' =&gt; array($from,$to));
      } else if ($from){
          $q = array('&gt;=' =&gt; $from);
      } else if ($to){
          $q = array('&lt;=' =&gt; $to);
      }
      $params[] = array($id, '=', $q, 0, $wildcard);
  }
  </code></pre>
  
  <p>This handles the case when the custom field is a date but the supplied $values is not a single value, but is instead an array with from and/or to values.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-17T18:39:09.737Z
Answers.Text: Can we get a patch on this? This was hurting one charity I worked for.
Answers.UserDisplayName: JohnFF
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-18T17:04:20.840Z
Answers.Text: I'm shortly away until Monday.
  If anyone can do the honours: the above code is inserted at line 1512 in the 4.6.14 code.
Answers.UserDisplayName: chriscant
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-23T11:22:52.220Z
Answers.Text: @JohnFF Here's my patch for 4.6.14: [link](http://www.phdcc.com/civicrm/CiviCRM4.6.14.CRM.Contact.BAO.Query.patch)
Answers.UserDisplayName: chriscant
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-17T14:14:58.237Z
Answers.LastActivityDate: 2016-03-17T14:14:58.237Z
Answers.UserDisplayName: chriscant
Body: <p>I've fairly recently upgraded from 4.4 to 4.6.12 in Drupal.
  We have a custom date field that is Searchable and Search by Range is Yes.
  This used to work but doesn't now: The error includes this:
  <em>No matches found for: 
  Start date In '20 May 2, 20 July 2' ...AND...</em>
  Searches for date fields not by range are OK.</p>
  
  <p>I've just tried this in the 4.7 WordPress demo (UK locale) and can repeat the problem there, though the no matches error report format is better.
  <a href="https://i.sstatic.net/IeVbl.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/IeVbl.png" alt="search for specific date"></a>
  <a href="https://i.sstatic.net/chtTw.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/chtTw.png" alt="search in date range fails"></a></p>
  
  <p>The specific date case is handled in convertFormValues() in 4.6.12 CRM/Contact/BAO/Query.php - but not in 4.7.2.</p>
  
  <p>Any suggestions for how to fix this?</p>
  
  <p>Thanks, Chris</p>
  
Tags: <profile>
Title: Date range profile search problem
ThreadText: # Date range profile search problem
  
  (Asked by: username_0 on 2016-02-26)
  
  I've fairly recently upgraded from 4.4 to 4.6.12 in Drupal.
  We have a custom date field that is Searchable and Search by Range is Yes.
  This used to work but doesn't now: The error includes this:
  *No matches found for:
  Start date In '20 May 2, 20 July 2' ...AND...*
  Searches for date fields not by range are OK.
  
  I've just tried this in the 4.7 WordPress demo (UK locale) and can repeat the problem there, though the no matches error report format is better.
  [![search for specific date](https://i.sstatic.net/IeVbl.png)](https://i.sstatic.net/IeVbl.png)
  [![search in date range fails](https://i.sstatic.net/chtTw.png)](https://i.sstatic.net/chtTw.png)
  
  The specific date case is handled in convertFormValues() in 4.6.12 CRM/Contact/BAO/Query.php - but not in 4.7.2.
  
  Any suggestions for how to fix this?
  
  Thanks, Chris
  
  **Tags:** profile
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-03-17. Score: 2
  
  In 4.6.12 CRM/Contact/BAO/Query.php I've added this case in convertFormValues() to fix this - someone may do it more beautifully:
  elseif (!empty($values) && is_array($values) && self::isCustomDateField($id)) {
      $from = FALSE;
      if (array_key_exists('from',$values)){
          $from = $values['from'];
          $from = CRM_Utils_Date::processDate($from);
      }
      $to = FALSE;
      if (array_key_exists('to',$values)){
          $to = $values['to'];
          $to = CRM_Utils_Date::processDate($to);
      }
      if( $from && $to){
          $q = array('BETWEEN' => array($from,$to));
      } else if ($from){
          $q = array('>=' => $from);
      } else if ($to){
          $q = array('<=' => $to);
      }
      $params[] = array($id, '=', $q, 0, $wildcard);
  }
  
  This handles the case when the custom field is a date but the supplied $values is not a single value, but is instead an array with from and/or to values.
  
  > **Comments:**
  > **username_1**: Can we get a patch on this? This was hurting one charity I worked for.  
  > **username_0**: I'm shortly away until Monday. If anyone can do the honours: the above code is inserted at line 1512 in the 4.6.14 code.  
  > **username_0**: @username_1 Here's my patch for 4.6.14: [link](http://www.phdcc.com/civicrm/CiviCRM4.6.14.CRM.Contact.BAO.Query.patch)  
  
  ---
  
  