Let's follow up this discussion at the Neptune Community

(this forum will be kept in read-only mode)

date Picker - minDate issue

Hi,


We have a DatePicker/sap.m field on the app and we have set the minDate attribute to today's date. 


This results in what we expect. User is unable to pick any date older than today's date. So far so good. However if the user selects todays date from the drop down then it wont accept the value. We dont default the date field. We want user to select the date each time. If the user chooses any date in the future all works fine as expected no issues at all. So the only issue we have is that if user selects today's date then it wont accept the value.


this is the code we are using in our INIT function. 

 

datPckrDelivDate.setMinDate(new Date());

  


Am i doing something wrong?
1 Comment

Hi Vijayendra,


Sorry for the late reply, but in case you have not resolved the issue you will hopefully get something useful out of this reply.

The new Date() function returns a timestamp, and this is the reason why the validation fails when selecting the current date. If you set the time to midnight for the date object it works fine.


Code example:

    var d = new Date();


    d.setHours(0);    

    d.setMinutes(0);

    d.setSeconds(0);

    d.setMilliseconds(0);


    datPckrDelivDate.setMinDate(d);


Kind regards,

Thomas

Login or Signup to post a comment