var udate = document.getElementById('id').value; var ddate = document.getElementById('id').value; udate = udate.split('-'); ddate = ddate.split('-'); udate = udate[2]; ddate = ddate[2]; numer = eval(ddate+'-'+udate);