title: JQuery Datepicker - Add Years
body: <p>I have added the JQuery Datepicker control to one of my ASP.Net pages. The page allows a user to add details about a piece of equipment. </p>
  
  <p>They can also select the date they bought the equipment using the Datepicker, then from a drop down list, select the warranty length (ie, 1,2,3,4,5 years etc) that comes with the equipment. Based on the warranty length they have selected, I need JQuery code to work out the date the warranty will expire for the Equipment, ie, if bought 21/02/2011, 3 year warrenty, then warranty expires 21/02/2014.</p>
  
  <p>I have looked at the other Datepicker examples on this site, but none seem to show how to add years to a date, rather just how to add days.</p>
  
  <p>This is my code so far</p>
  
  <pre><code>$('#equipment_purchaseDate').datepicker({ dateFormat: 'dd/mm/yy', onSelect: function (dateStr) {
          var d = $.datepicker.parseDate('dd/mm/yy', dateStr);
          d.setDate(d.getDate() + ($('#equipment_warrantyLength').val() * 365)); //multiple warranty length by 365 to get years, then add to startDate
          $('#equipment_warrentyExpires').datepicker('setDate', d);
      } 
  });
  </code></pre>
  
  <p>However this doesn't seem to be working correctly.</p>
  
  <p>Any feedback would be much appreciated.</p>
  
  <p>Thanks.</p>