--- sites/all/modules/apachesolr/apachesolr_search.module 2009-10-22 11:37:48.000000000 +1300 +++ /home/stuart/sites/reaa_dev/modules/acquia/apachesolr/apachesolr_search.module 2009-10-22 12:49:48.000000000 +1300 @@ -454,8 +454,12 @@ function apachesolr_search_date_range($q // facet.date.* params from the DB and determine the best search // gap to use. This callback assumes $delta is 'changed' or 'created'. if (!isset($start_iso)) { - $start_iso = apachesolr_date_iso(db_result(db_query("SELECT MIN($facet_field) FROM {node} WHERE status = 1"))); - $end_iso = apachesolr_date_iso(db_result(db_query("SELECT MAX($facet_field) FROM {node} WHERE status = 1"))); + $min = db_result(db_query("SELECT MIN($facet_field) FROM {node} WHERE status = 1")); + $start_date = strtotime(date('Y-01-01'), $min); // start of the year + $start_iso = apachesolr_date_iso($start_date); + $max = db_result(db_query("SELECT MAX($facet_field) FROM {node} WHERE status = 1")); + $end_date = strtotime(date('Y-12-31 23:59:59', $max)); + $end_iso = apachesolr_date_iso($end_date); $gap = apachesolr_date_determine_gap($start_iso, $end_iso); } // Return a query range from the beginning of a gap period to the beginning