X-Git-Url: https://git.rvb.name/weathermon.git/blobdiff_plain/769d0bd71b19b467c195838379a379e0e2d69c2b..de2440e167bacd1cebff432611d5d837dfeddffd:/web/image_minmax.php

diff --git a/web/image_minmax.php b/web/image_minmax.php
index 183942b..edc1708 100644
--- a/web/image_minmax.php
+++ b/web/image_minmax.php
@@ -48,8 +48,7 @@ if ($type and $param) {
   }                                                                
 
   $q = $db -> prepare(
-    'select st.st_fill_color_top,st.st_fill_color_bottom,st.st_description,u.id,u.unit_group from st_parameters st,units u where st.id='.$param.' and st.st_unit=u.id
-'
+    'select st.st_fill_color_top,st.st_fill_color_bottom,st.st_description,u.id,u.unit_group from st_parameters st,units u where st.id='.$param.' and st.st_unit=u.id'
   );
   $q -> execute();
 
@@ -100,8 +99,11 @@ if ($type and $param) {
     
     }
 
+    $datestr=sprintf("%04d%02d01",$year,$month);
+    $nextdatestr=sprintf("%04d%02d01",$next_year,$next_month);
+
     $q = $db -> prepare(
-      '
+     '
         select 
           x,
           unitconv(min(min),'.$from_unit.','.$to_unit.') min_value,
@@ -114,14 +116,14 @@ if ($type and $param) {
           from 
             sensors_ranges 
           where 
-            day>=str_to_date(\''.$year.$month.'\',\'%Y%m\')
-            and day<str_to_date(\''.$next_year.$next_month.'\',\'%Y%m\')
+            day>=STR_TO_DATE(\''.$datestr.'\',\'%Y%m%d\')
+            and day<STR_TO_DATE(\''.$nextdatestr.'\',\'%Y%m%d\')
             and sensor='.$sensor.'
             and parameter='.$param.'
           ) t group by x
         order by x'
     );
-    
+
   } elseif ($type == "year") {
 
     $next_year = $year+1;
@@ -134,6 +136,9 @@ if ($type and $param) {
                           
     }
 
+    $datestr=sprintf("%04d0101",$year);
+    $nextdatestr=sprintf("%04d0101",$next_year);
+
     $q = $db -> prepare(
       '
         select 
@@ -150,8 +155,8 @@ if ($type and $param) {
           from 
             sensors_ranges
           where 
-            day>=str_to_date(\''.$year.'\',\'%Y\')
-            and day<str_to_date(\''.$next_year.'\',\'%Y\')
+            day>=STR_TO_DATE(\''.$datestr.'\',\'%Y%m%d\')
+            and day<STR_TO_DATE(\''.$nextdatestr.'\',\'%Y%m%d\')
             and sensor='.$sensor.'
             and parameter='.$param.'
           ) t group by x
@@ -187,7 +192,6 @@ if ($type and $param) {
     
   }                                                                
 
-
   // Create the graph
   $g->graph_theme = null;