=== modified file 'sites/all/modules/statspro/statspro.inc'
--- sites/all/modules/statspro/statspro.inc	2010-08-30 12:10:30 +0000
+++ sites/all/modules/statspro/statspro.inc	2010-08-31 18:15:44 +0000
@@ -239,13 +239,14 @@
     $max = ($day_of_week == 0)  ? 'today' : 'next sunday';
     $max = strtotime($max, $reference);
     if (!$use_timestamp) {
-      $max = date('Ymd', $max);
+      $max = date('Y-m-d', $max);
+      return sprintf('(%s >= \'%s\' AND %1$s <= \'%s\')', $field, $min, $max);
     }
     return $this->get_min_max_period($field, $min, $max);
   }
 
   /**
-   * Returns a YYYYMMDD date representation of the first day of same the week
+   * Returns a YYYY-MM-DD date representation of the first day of same the week
    * as the reference day.
    *
    * @param <int> $reference A timestamp representaing the reference day.
@@ -256,7 +257,7 @@
     $first = ($day_of_week == 1) ? 'today' : 'previous monday';
     $first = strtotime($first, $reference);
     if (!$use_timestamp) {
-      $first = date('Ymd', $first);
+      $first = date('Y-m-d', $first);
     }
     return $first;
   }
@@ -270,11 +271,14 @@
   protected function get_month_from_reference($reference, $field, $use_timestamp) {
     $min = $this->get_first_day_of_month_from_reference($reference, $use_timestamp);
     $max = $this->get_last_day_of_month_from_reference($reference, $use_timestamp);
+    if (!$use_timestamp) {
+      return sprintf('(%s >= \'%s\' AND %1$s <= \'%s\')', $field, $min, $max);
+    }
     return $this->get_min_max_period($field, $min, $max);
   }
 
   /**
-   * Returns a YYYYMMDD date representation of the first day of same the month
+   * Returns a YYYY-MM-DD date representation of the first day of same the month
    * as the reference day.
    *
    * @param <int> $reference A timestamp representaing the reference day.
@@ -284,15 +288,14 @@
     $year = date('Y', $reference);
     $month = date('m', $reference);
     $first = $year . '-' . $month . '-01';
-    $first = strtotime($first);
-    if (!$use_timestamp) {
-      $first = date('Ymd', $first);
+    if ($use_timestamp) {
+      return strtotime($first);
     }
     return $first;
   }
 
   /**
-   * Returns a YYYYMMDD date representation of the last day of same the month
+   * Returns a YYYY-MM-DD date representation of the last day of same the month
    * as the reference day.
    *
    * @param <int> $reference A timestamp representaing the reference day.
@@ -313,13 +316,13 @@
     }
     $last = strtotime($last);
     if (!$use_timestamp) {
-      $last = date('Ymd', $last);
+      $last = date('Y-m-d', $last);
     }
     return $last;
   }
 
   /**
-   * Returns a YYYYMMDD date representation of the first day of same the quarter
+   * Returns a YYYY-MM-DD date representation of the first day of same the quarter
    * as the reference day.
    *
    * @param <int> $reference A timestamp representaing the reference day.
@@ -328,7 +331,7 @@
   protected function get_first_day_of_quarter_from_reference($reference, $use_timestamp) {
     $year = date('Y', $reference);
     $first_month_of_quarter = $this->get_first_month_of_quarter_from_reference($reference);
-    $first = sprintf('%04u%02u01', $year, $first_month_of_quarter);
+    $first = sprintf('%04u-%02u-01', $year, $first_month_of_quarter);
     if ($use_timestamp) {
       $first = strtotime($first);
     }
@@ -336,7 +339,7 @@
   }
 
   /**
-   * Returns a YYYYMMDD date representation of the last day of same the quarter
+   * Returns a YYYY-MM-DD date representation of the last day of same the quarter
    * as the reference day.
    *
    * @param <int> $reference A timestamp representaing the reference day.
@@ -357,7 +360,7 @@
     }
     $last = strtotime($last);
     if (!$use_timestamp) {
-      $last = date('Ymd', $last);
+      $last = date('Y-m-d', $last);
     }
     return $last;
   }
@@ -389,7 +392,7 @@
   }
 
   /**
-   * Returns a YYYYMMDD date representation of the first day of same the year
+   * Returns a YYYY-MM-DD date representation of the first day of same the year
    * as the reference day.
    *
    * @param <int> $reference A timestamp representaing the reference day.
@@ -397,7 +400,7 @@
    */
   protected function get_first_day_of_year_from_reference($reference, $use_timestamp) {
     $year = date('Y', $reference);
-    $first = sprintf('%04u0101', $year);
+    $first = sprintf('%04u-01-01', $year);
     if ($use_timestamp) {
       $first = strtotime($first);
     }
@@ -405,7 +408,7 @@
   }
 
   /**
-   * Returns a YYYYMMDD date representation of the last day of same the quarter
+   * Returns a YYYY-MM-DD date representation of the last day of same the quarter
    * as the reference day.
    *
    * @param <int> $reference A timestamp representaing the reference day.
@@ -413,7 +416,7 @@
    */
   protected function get_last_day_of_year_from_reference($reference, $use_timestamp) {
     $year = date('Y', $reference);
-    $last = $use_timestamp ? sprintf('%04u0101', $year + 1) : sprintf('%04u1231', $year);
+    $last = $use_timestamp ? sprintf('%04u-01-01', $year + 1) : sprintf('%04u-12-31', $year);
     if ($use_timestamp) {
       $last = strtotime($last);
     }
@@ -436,8 +439,8 @@
         return sprintf('%s >= %u', $field, $timestamp_starting_date);
       }
       else {
-        $starting_date = date('Ymd', $timestamp_starting_date);
-        return sprintf('%s >= %u', $field, $starting_date);
+        $starting_date = date('Y-m-d', $timestamp_starting_date);
+        return sprintf('%s >= \'%s\'', $field, $starting_date);
       }
     }
     else {
@@ -448,8 +451,8 @@
             return sprintf('%s >= %u', $field, $timestamp_begining_today);
           }
           else {
-            $today = date('Ymd', $now);
-            return sprintf('%s = %u', $field, $today);
+            $today = date('Y-m-d', $now);
+            return sprintf('%s = \'%s\'', $field, $today);
           }
           break;
 
@@ -460,14 +463,19 @@
             return $this->get_min_max_period($field, $min, $max);
           }
           else {
-            $day = date('Ymd', strtotime('-1 day', $now));
-            return sprintf('%s = %u', $field, $day);
+            $day = date('Y-m-d', strtotime('-1 day', $now));
+            return sprintf('%s = \'%s\'', $field, $day);
           }
           break;
 
         case 'week_current':
           $min = $this->get_first_day_of_week_from_reference($now, $use_timestamp);
-          return sprintf('%s >= %u', $field, $min);
+          if ($use_timestamp) {
+            return sprintf('%s >= %u', $field, $min);
+          }
+          else {
+            return sprintf('%s >= \'%s\'', $field, $min);
+          }
           break;
 
         case 'week_last':
@@ -482,7 +490,12 @@
 
         case 'month_current':
           $min = $this->get_first_day_of_month_from_reference($now, $use_timestamp);
-          return sprintf('%s >= %u', $field, $min);
+          if ($use_timestamp) {
+            return sprintf('%s >= %u', $field, $min);
+          }
+          else {
+            return sprintf('%s >= \'%s\'', $field, $min);
+          }
           break;
 
         case 'month_last':
@@ -493,37 +506,67 @@
         case 'month_last3':
           $reference = strtotime('-3 month', $now);
           $min = $this->get_first_day_of_month_from_reference($reference, $use_timestamp);
-          return sprintf('%s >= %u', $field, $min);
+          if ($use_timestamp) {
+            return sprintf('%s >= %u', $field, $min);
+          }
+          else {
+            return sprintf('%s >= \'%s\'', $field, $min);
+          }
           break;
 
         case 'month_last6':
           $reference = strtotime('-6 month', $now);
           $min = $this->get_first_day_of_month_from_reference($reference, $use_timestamp);
-          return sprintf('%s >= %u', $field, $min);
+          if ($use_timestamp) {
+            return sprintf('%s >= %u', $field, $min);
+          }
+          else {
+            return sprintf('%s >= \'%s\'', $field, $min);
+          }
           break;
 
         case 'quarter_current':
           $min = $this->get_first_day_of_quarter_from_reference($now, $use_timestamp);
-          return sprintf('%s >= %u', $field, $min);
+          if ($use_timestamp) {
+            return sprintf('%s >= %u', $field, $min);
+          }
+          else {
+            return sprintf('%s >= \'%s\'', $field, $min);
+          }
           break;
 
         case 'quarter_last':
           $reference = strtotime('-3 month', $now);
           $min = $this->get_first_day_of_quarter_from_reference($reference, $use_timestamp);
           $max = $this->get_last_day_of_quarter_from_reference($reference, $use_timestamp);
-          return $this->get_min_max_period($field, $min, $max);
+          if ($use_timestamp) {
+            return $this->get_min_max_period($field, $min, $max);
+          }
+          else {
+            return sprintf('(%s >= \'%s\' AND %1$s <= \'%s\')', $field, $min, $max);
+          }
           break;
 
         case 'year_current':
           $min = $this->get_first_day_of_year_from_reference($now, $use_timestamp);
-          return sprintf('%s >= %u', $field, $min);
+          if ($use_timestamp) {
+            return sprintf('%s >= %u', $field, $min);
+          }
+          else {
+            return sprintf('%s >= \'%s\'', $field, $min);
+          }
           break;
 
         case 'year_last':
           $reference = strtotime('-1 year', $now);
           $min = $this->get_first_day_of_year_from_reference($reference, $use_timestamp);
           $max = $this->get_last_day_of_year_from_reference($reference, $use_timestamp);
-          return $this->get_min_max_period($field, $min, $max);
+          if ($use_timestamp) {
+            return $this->get_min_max_period($field, $min, $max);
+          }
+          else {
+            return sprintf('(%s >= \'%s\' AND %1$s <= \'%s\')', $field, $min, $max);
+          }
           break;
 
         default:

