Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 1.7, 1.8
-
Fix Version/s: 1.8
-
Component/s: Core CiviCRM
-
Labels:None
Description
end_date style queries (ie. op is <=) do not work under mysql 5.0.41. The problem is how the date is formatted by dateQueryBuilder in CRM/Contact/BAO/Query.php does not cast correctly to a DATE.
For example:
SELECT DISTINCT(contact_a.id) as contact_id, contact_a.contact_type as contact_type, contact_a.sort_name as sort_name, contact_a.display_name as display_name, civicrm_membership.id as membership_id, civicrm_membership.join_date as join_date, civicrm_membership_type.name as membership_type, civicrm_membership.source as source, civicrm_membership.status_id as status_id, civicrm_membership.start_date as start_date, civicrm_membership.end_date as end_date, civicrm_membership.owner_membership_id as owner_membership_id FROM civicrm_contact contact_a INNER JOIN civicrm_membership ON civicrm_membership.contact_id = contact_a.id INNER JOIN civicrm_membership_type ON civicrm_membership.membership_type_id = civicrm_membership_type.id WHERE ( civicrm_membership.end_date >= '20070601' AND civicrm_membership.end_date <= '20070630235959' ) AND ( 1 ) ORDER BY end_date desc LIMIT 0, 50;
the problem (returns dates <= '2007-12-31' ):
AND civicrm_membership.end_date <= '20070630235959'
Any of these work:
AND civicrm_membership.end_date <= 20070630235959
AND civicrm_membership.end_date <= '2007-06-30 23:59:59'
AND civicrm_membership.end_date <= '20070629'
AND civicrm_membership.end_date <= CAST('20070630235959' AS DATE)