Index: /trunk/MagicSoft/Mars/datacenter/db/builddatasets.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/builddatasets.php	(revision 8332)
+++ /trunk/MagicSoft/Mars/datacenter/db/builddatasets.php	(revision 8333)
@@ -451,5 +451,5 @@
         printf("<p>");
         PrintSourceMenu($host,$user,$pw,$db);
-        PrintNightRangeMenu($host,$user,$pw,$db);
+        PrintNightRangeMenu($host,$user,$pw,$db, "Sequences");
         PrintStarRangeMenu($host,$user,$pw,$db);
         printf("<p>");
@@ -930,4 +930,5 @@
     $siteuser="dcdb";
 
+
     if (!isset($_SERVER['PHP_AUTH_USER']) || crypt($_SERVER['PHP_AUTH_PW'], $sitepw)!=$sitepw || $_SERVER['PHP_AUTH_USER']!=$siteuser)
     {
Index: /trunk/MagicSoft/Mars/datacenter/db/findoffdata.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/findoffdata.php	(revision 8332)
+++ /trunk/MagicSoft/Mars/datacenter/db/findoffdata.php	(revision 8333)
@@ -349,5 +349,5 @@
         PrintSourceMenu($host,$user,$pw,$db);
         printf("<p>\n");
-        PrintNightRangeMenu($host,$user,$pw,$db);
+        PrintNightRangeMenu($host,$user,$pw,$db, "Sequences");
         printf("<p>\n");
 
Index: /trunk/MagicSoft/Mars/datacenter/db/include.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/include.php	(revision 8332)
+++ /trunk/MagicSoft/Mars/datacenter/db/include.php	(revision 8333)
@@ -223,4 +223,29 @@
 
     return $max;
+}
+
+function GetMaxDate($field, $table, $host, $user, $pw, $db)
+{
+    $db_id = mysql_connect($host, $user, $pw);
+    if ($db_id==FALSE)
+    {
+            printf("mysql_connect returned the following error:<br>");
+            printf("%s<br>", mysql_error());
+            die("");
+    }
+
+    $query  = "SELECT DATE_FORMAT(if(MAX(" . $field . ")<'13:00:00', MAX(" . $field . "), ADDDATE(MAX(" . $field . "), INTERVAL +1 DAY)), '%Y-%m-%d') FROM " . $db . "." . $table;
+    $result = mysql_query($query);
+    if (!$result)
+        return "0";
+
+    $row = mysql_fetch_row($result);
+
+    $maxdate = $row[0];
+
+    mysql_free_result($result);
+    mysql_close($db_id);
+
+    return $maxdate;
 }
 
Index: /trunk/MagicSoft/Mars/datacenter/db/menu.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/menu.php	(revision 8332)
+++ /trunk/MagicSoft/Mars/datacenter/db/menu.php	(revision 8333)
@@ -483,15 +483,15 @@
 }
 
-function PrintNightRangeMenu($host,$user,$pw,$db)
+function PrintNightRangeMenu($host,$user,$pw,$db, $table)
 {
     if (empty($_GET["fStartDate"]))
-        $timemin = GetMin("fRunStart", "Sequences", $host, $user, $pw, $db);
+        $timemin = GetMin("fRunStart", $table, $host, $user, $pw, $db);
     else
         $timemin = $_GET["fStartDate"];
 
     if (empty($_GET["fStopDate"]))
-        $timemax = GetMax("fRunStart", "Sequences", $host, $user, $pw, $db);
+        $timemax = GetMaxDate("fRunStart", $table, $host, $user, $pw, $db);
     else
-            $timemax = $_GET["fStopDate"];
+        $timemax = $_GET["fStopDate"];
 
     printf("Night&nbsp;(yyyy-mm-dd)&nbsp;from&nbsp;<input name=\"fStartDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"%s\">\n", $timemin);
Index: /trunk/MagicSoft/Mars/datacenter/db/runinfo-aio.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/runinfo-aio.php	(revision 8332)
+++ /trunk/MagicSoft/Mars/datacenter/db/runinfo-aio.php	(revision 8333)
@@ -248,5 +248,5 @@
         printf(" <div id='ranges' style='display:none'>");
         PrintSequMenu($host,$user,$pw,$db);
-        PrintNightRangeMenu($host,$user,$pw,$db);
+        PrintNightRangeMenu($host,$user,$pw,$db, "RunData");
         printf("<p>");
         PrintZdRangeMenu($host,$user,$pw,$db);
Index: /trunk/MagicSoft/Mars/datacenter/db/sequinfo-aio.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/sequinfo-aio.php	(revision 8332)
+++ /trunk/MagicSoft/Mars/datacenter/db/sequinfo-aio.php	(revision 8333)
@@ -308,5 +308,5 @@
         printf("<p>");
         PrintSourceMenu($host,$user,$pw,$db);
-        PrintNightRangeMenu($host,$user,$pw,$db);
+        PrintNightRangeMenu($host,$user,$pw,$db, "Sequences");
         printf("<p>");
         printf("</div>");
