Index: Tmp/trunk/wp-includes/general-template.php
===================================================================
--- Tmp/trunk/wp-includes/general-template.php	(revision 10613)
+++ Tmp/trunk/wp-includes/general-template.php	(working copy)
@@ -1024,8 +1024,9 @@
 	<tr>';
 
 	// Get days with posts
+	$nextmonth=$thismonth+1;
 	$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
-		FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
+		FROM $wpdb->posts WHERE '{$thisyear}-{$nextmonth}-01 00:00:00' >= post_date and post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
 		AND post_type = 'post' AND post_status = 'publish'
 		AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
 	if ( $dayswithposts ) {
@@ -1044,7 +1045,7 @@
 	$ak_titles_for_day = array();
 	$ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
 		."FROM $wpdb->posts "
-		."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
+		."WHERE '{$thisyear}-{$nextmonth}-01 00:00:00' >= post_date and post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
 		."AND post_date < '".current_time('mysql')."' "
 		."AND post_type = 'post' AND post_status = 'publish'"
 	);
