From a0a31ec3e23f8ac900ac82ad569131d07f0c5b7c Mon Sep 17 00:00:00 2001 From: Michael Douchin Date: Wed, 25 Oct 2023 16:35:57 +0200 Subject: [PATCH] Form filter - Date range: add a day to the max values when requesting data --- assets/src/legacy/filter.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/assets/src/legacy/filter.js b/assets/src/legacy/filter.js index f403f9388b..1bf816da31 100644 --- a/assets/src/legacy/filter.js +++ b/assets/src/legacy/filter.js @@ -651,7 +651,16 @@ var lizLayerFilterTool = function () { // max date filter if (max_val && Date.parse(max_val)) { - filters.push('( "' + startField + '"' + " <= '" + max_val + "'" + " OR " + ' "' + endField + '"' + " <= '" + max_val + "' )"); + // Add one day to the max values as we cannot select hours + // This allow to select features with the max value. Eg a feature with 2023-10-25 12:20:01 + // must be selected if max date is 2023-10-25 wich is indeed 2023-10-25 00:00:00 + let max_val_new = new Date(Date.parse(max_val)); + // Add a day + max_val_new.setDate(max_val_new.getDate() + 1); + // Truncate to keep only date & transform into string + let max_val_new_str = formatDT(max_val_new, 'yy-mm-dd'); + // We use strict < instead of <= because we just add a day to the max value + filters.push('( "' + startField + '"' + " < '" + max_val_new_str + "'" + " OR " + ' "' + endField + '"' + " < '" + max_val_new_str + "' )"); } else { max_val = null; }