diff --git a/src/static/dashboard.html b/src/static/dashboard.html
index 114f336..3d5fc8e 100644
--- a/src/static/dashboard.html
+++ b/src/static/dashboard.html
@@ -1278,6 +1278,7 @@
if (!response.ok) { strip.style.display = 'none'; return; }
const stats = await response.json();
const fmtDate = (value) => new Date(value).toLocaleDateString([], { day: 'numeric', month: 'short', year: 'numeric' });
+ state.dbFirstDate = String(stats.first_timestamp).slice(0, 10); // feeds the All-time date range
$('db-total').textContent = Number(stats.total_measurements).toLocaleString();
if (stats.rid_measurements != null) {
const fmtNum = (value) => Number(value || 0).toLocaleString();
@@ -1320,15 +1321,13 @@
if ($('history-range').value === 'custom') return;
state.useDates = false;
const hours = Number($('history-range').value);
- if (hours >= 876000) {
- $('history-start').value = ''; $('history-end').value = '';
- } else {
- // Mirror the chosen range into the date pickers (local dates)
- const isoLocal = (d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
- const now = new Date();
- $('history-end').value = isoLocal(now);
- $('history-start').value = isoLocal(new Date(now.getTime() - hours * 3600 * 1000));
- }
+ // Mirror the chosen range into the date pickers (local dates)
+ const isoLocal = (d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
+ const now = new Date();
+ $('history-end').value = isoLocal(now);
+ $('history-start').value = hours >= 876000
+ ? (state.dbFirstDate || '2018-08-01') // All time: DB's first record
+ : isoLocal(new Date(now.getTime() - hours * 3600 * 1000));
if (state.selectedStation) loadHistory(state.selectedStation);
else $('history-status').textContent = 'Select a station first — click one on the map or in the list';
});