--- includes/date_api_filter_handler.inc	2008-10-31 19:42:27.000000000 +0800
+++ includes/date_api_filter_handler.inc.new	2008-11-07 04:12:48.000000000 +0800
@@ -37,6 +37,7 @@ class date_api_filter_handler extends vi
     parent::options($options);
     $options['date_fields'] = array();
     $options['date_method'] = 'OR';
+	$options['date_distinct'] = 0;
     $options['granularity'] = 'day';
     $options['form_type'] = 'date_select';
     $options['default_date'] = '';
@@ -102,6 +103,12 @@ class date_api_filter_handler extends vi
       '#default_value' => $this->options['date_method'],
       '#description' => t('Method of handling multiple date fields in the same query. Return items that have any matching date field (date = field_1 OR field_2), or only those with matches in all selected date fields (date = field_1 AND field_2).'),
       );
+	$form['date_distinct'] = array(
+      '#title' => t('Distinct support'),
+      '#type' => 'checkbox',
+	  '#default_value' => $this->options['date_distinct'],
+	  '#description' => t('If more than one value in selected date repeat field of a node match the criteria, this filter returns duplicate entries of the node. If you want to use the distinct function to eliminate duplicates of nodes, please enable both this option and the distinct function in this view. This should be disabled for any calendar view as it makes a node to be displayed only for once.'),
+    );
   }
 
   function extra_options_validate($form, &$form_state) {
@@ -427,7 +434,9 @@ class date_api_filter_handler extends vi
         // remove it if it is a duplicate, since that will break the query.
         $this->query->add_table($field['table_name'], NULL, NULL, $field['table_name']);
         // Make sure the real field is added to the query.
-        $this->query->add_field($field['table_name'], $field['field_name']);
+        if ($this->options['date_distinct'] == 0) {
+		  $this->query->add_field($field['table_name'], $field['field_name']);
+		}
         foreach ($field['related_fields'] as $related) {
           $bits = explode('.', $related);
           if ($bits[1] != $field['field_name']) {
