Index: template-functions-links.php
===================================================================
--- template-functions-links.php	(revision 2419)
+++ template-functions-links.php	(working copy)
@@ -485,18 +485,30 @@
     }
 }
 
+function count_pages($what_to_count) {
+	global $request, $posts_per_page, $wpdb;
+
+	preg_match('#FROM (.*) GROUP BY#', $request, $matches);
+	$fromwhere = $matches[1];
+        $fromwhere = preg_replace("(/\*TAG\*/.*/\*TAG\*/)","",$fromwhere);
+	$numposts = $wpdb->get_var("SELECT COUNT($what_to_count) FROM $fromwhere");
+	return (ceil($numposts / $posts_per_page));
+}
+
 function posts_nav_link($sep=' &#8212; ', $prelabel='&laquo; Previous Page', $nxtlabel='Next Page &raquo;') {
-	global $request, $posts_per_page, $wpdb;
 	if (! is_single()) {
+		switch (get_query_var('what_to_show')) {
+		case 'posts':
+			$max_page = count_pages('ID');
+			break;
 
-		if (get_query_var('what_to_show') == 'posts') {
-			preg_match('#FROM (.*) GROUP BY#', $request, $matches);
-			$fromwhere = $matches[1];
-			$numposts = $wpdb->get_var("SELECT COUNT(ID) FROM $fromwhere");
-			$max_page = ceil($numposts / $posts_per_page);
-		} else {
+		case 'days':
+			$max_page = count_pages('DISTINCT DATE_FORMAT(post_date, \'%d %m %Y\')');
+			break;
+
+		default:
 			$max_page = 999999;
-		}
+	}
 
         if ($max_page > 1) {
             previous_posts_link($prelabel);
Index: classes.php
===================================================================
--- classes.php	(revision 2419)
+++ classes.php	(working copy)
@@ -525,9 +525,9 @@
 				$end_date = $wpdb->get_var("SELECT min(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $endrow,1");
 
 				if ($page > 1) {
-					$where .= " AND post_date >= '$end_date' AND post_date <= '$start_date'";
+					$where .= " /*TAG*/ AND post_date >= '$end_date' AND post_date <= '$start_date' /*TAG*/";
 				} else {
-					$where .= " AND post_date >= '$end_date'";
+					$where .= " /*TAG*/ AND post_date >= '$end_date' /*TAG*/";
 				}
 			}
 		}

