--- a/kohaBar-daemon/trunk/kohabard.php
+++ b/kohaBar-daemon/trunk/kohabard.php
@@ -67,22 +67,31 @@
 
   foreach ( $branchCodes as $thisBranch ) {
     $today = $year . '-' . $month . '-' . $day;
-    $sql = "SELECT COUNT(*) as checkouts FROM statistics WHERE (statistics.datetime >= '$today' AND statistics.type = 'issue' AND statistics.branch = '$thisBranch')";
+    $sql = "SELECT COUNT(*) as checkouts FROM statistics 
+    WHERE ( DATE( statistics.datetime ) >= DATE( '$today')
+    AND ( statistics.type = 'issue' OR statistics.type = 'renew' ) 
+    AND statistics.branch = '$thisBranch')";
     $results = mysql_query( $sql ) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $sql . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());
     $row = mysql_fetch_assoc( $results );
     $checkoutsToday[ $thisBranch ] = $row['checkouts'];
     if ( $debug ) { echo "\n Checkouts for Today SQL: \n$sql \n" . $row['checkouts']; }
 
 
-    $today = $year . '-' . $month . '-' . '00';
-    $sql = "SELECT COUNT(*) as checkouts FROM statistics WHERE (statistics.datetime >= '$today' AND statistics.type = 'issue' AND statistics.branch = '$thisBranch')";
+    $today = $year . '-' . $month . '-' . '01';
+    $sql = "SELECT COUNT(*) as checkouts FROM statistics 
+    WHERE ( DATE( statistics.datetime ) >= DATE( '$today' )
+    AND ( statistics.type = 'issue' OR statistics.type = 'renew' )
+    AND statistics.branch = '$thisBranch')";
     $results = mysql_query( $sql ) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $sql . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());
     $row = mysql_fetch_assoc( $results );
     $checkoutsMonthToDate[ $thisBranch ] = $row['checkouts'];
     if ( $debug ) { echo "\n Checkouts for Month SQL: \n$sql \n" . $row['checkouts']; }
   
-    $today = $year . '-' . '00' . '-' . '00';
-    $sql = "SELECT COUNT(*) as checkouts FROM statistics WHERE (statistics.datetime >= '$today' AND statistics.type = 'issue' AND statistics.branch = '$thisBranch')";
+    $today = $year . '-' . '01' . '-' . '01';
+    $sql = "SELECT COUNT(*) as checkouts FROM statistics 
+    WHERE ( DATE( statistics.datetime ) >= DATE( '$today' )
+    AND ( statistics.type = 'issue' OR statistics.type = 'renew' ) 
+    AND statistics.branch = '$thisBranch')";
     $results = mysql_query( $sql ) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $sql . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());
     $row = mysql_fetch_assoc( $results );
     $checkoutsYearToDate[ $thisBranch ] = $row['checkouts'];