diff --git a/sources/application/search/criterionconversion/criteriontosearchform.class.inc.php b/sources/application/search/criterionconversion/criteriontosearchform.class.inc.php index 34a003e64c..e559813ca4 100644 --- a/sources/application/search/criterionconversion/criteriontosearchform.class.inc.php +++ b/sources/application/search/criterionconversion/criteriontosearchform.class.inc.php @@ -360,12 +360,17 @@ class CriterionToSearchForm extends CriterionConversionAbstract $sDate = $aCriteria['values'][0]['value']; $oDate = new DateTime($sDate); + $sFirstDateValue = $oDate->format(AttributeDateTime::GetSQLFormat()); + $sFirstDateLabel = AttributeDateTime::GetFormat()->Format($sFirstDateValue); + $aCriteria['values'][0] = array('value' => $sFirstDateValue, 'label' => $sFirstDateLabel); + + $oDate->add(DateInterval::createFromDateString('1 day')); $oDate->sub(DateInterval::createFromDateString('1 second')); - $sLastDate = $oDate->format(AttributeDateTime::GetSQLFormat()); - $sLastDate = AttributeDateTime::GetFormat()->Format($sLastDate); - $aCriteria['values'][1] = array('value' => $sLastDate, 'label' => $sLastDate); + $sLastDateValue = $oDate->format(AttributeDateTime::GetSQLFormat()); + $sLastDateLabel = AttributeDateTime::GetFormat()->Format($sLastDateValue); + $aCriteria['values'][1] = array('value' => $sLastDateValue, 'label' => $sLastDateLabel); } } diff --git a/test/application/search/CriterionConversionTest.php b/test/application/search/CriterionConversionTest.php index 38cf022d05..5d0887808a 100644 --- a/test/application/search/CriterionConversionTest.php +++ b/test/application/search/CriterionConversionTest.php @@ -361,6 +361,10 @@ class CriterionConversionTest extends ItopDataTestCase 'Date between 3' => array('OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-01 00:00:00' >= start_date"), 'Date between 4' => array('OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-01 01:00:00' > start_date"), 'Date between 5' => array('OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-02 00:00:00' > start_date"), + 'Date between 6' => array('OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01' AND '2017-01-02' >= start_date"), + 'Date between 7' => array('OQL' => "SELECT CustomerContract WHERE ((start_date >= '2018-03-01') AND (start_date < '2018-04-01'))"), + 'Date =' => array('OQL' => "SELECT CustomerContract WHERE (start_date = '2018-03-01')"), + 'Date =2' => array('OQL' => "SELECT UserRequest WHERE (DATE_FORMAT(start_date, '%Y-%m-%d') = '2018-03-21')"), 'Num between 1' => array('OQL' => "SELECT Server WHERE nb_u >= 0 AND 1 >= nb_u"), ); }