Month selection not working properly after setting the dates dinamically