cancel
Showing results for 
Search instead for 
Did you mean: 

Handle console error message 'dateValue does not match min/max date range'

PiotrLesinski
Discoverer
0 Kudos

Hi All

I have multiple datePickers. All set in XML view

<DatePicker id="DP1" value="{path:'oModel>StartDate', type:'sap.ui.model.type.Date', formatOptions: { style: 'medium', strictParsing: true}}" placeholder="FROM:  DD/MM/YYYY" minDate="{oModel>/CurrentDate}" maxDate="{oModel>/EndDate}" enabled="false" editable="true"/>

Dates startDate and endDate are comes from backend. MinDate is set in controller, always Today. In some cases date (startDate) is less than minDate. DatePicker works fine. When user opening calendar only days EQ or GT than today are available. 

But in console I get errors like:

PiotrLesinski_1-1709046118719.png

The point is to have clean console.

Thanks,

Piotr

 

 

View Entire Topic
Edrilan_Berisha
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Piotr,

 

I think the error message tells you what the issue is. From backend you set the maxDate as Dec 31, 9999. While the datepicker is picking a datetime not just a date. You compare dates with datetimes. Can you adjust that and see if the error is gone. So you provide the same format DD/MM/YYYY HH:mm:ss. Something like this.

 

Best,

Edrilan Berisha

SAP S/4HANA Cloud Financials Development

PiotrLesinski
Discoverer
0 Kudos

Hi Edrilan

When I use only VALUE I can use Date object or Sting ( format DD/MM/YYYY HH:mm:ss ). But when I add minDate and pass string to minDate I receive error: ' Error: Date must be a JavaScript date object'. If value is between min/maxDate there is no error message.

I partially resolve the error message by removing from the XML: 

type:'sap.ui.model.type.Date', formatOptions: { style: 'medium', strictParsing: true}

But then displayFormat doesn't work and DatePicker loads the initial dates as
Friday, December 31, 9999, 12:00:00 GMT+0100 (Central European Standard Time)

And when I fix it with a formatter and pass a String or Date object, the error returns in the console