title: Trying to subtract 5 days from a defined date - Google App Script
body: <p>I'm trying to write a script which is supposed to send out an email and create two calender entries when submitting a form. To be honest, this is my first script and I am very happy that the email is send out and the calender entries are working as well. The thing which gives me a headache is to subtract 5 days (actually x days) from a defined date. </p>
  
  <p>First I thought I could simply do something like </p>
  
  <pre><code>var liveday = e.values[2];
  var newday = liveday-5;
  </code></pre>
  
  <p>well, this didn't work :-) </p>
  
  <p>I tried more: </p>
  
  <pre><code>var newtime = new Date(liveday);
  var yr = newtime.getYear();
  var dt = newtime.getDay();
  var mt = newtime.getMonth();
  var dtnew = dtnew.setDate(mt, dt-5, yr);
  </code></pre>
  
  <p>But here I received <code>1418256000000</code> whereas liveday = 12/01/2014. Not sure why days were added, rather than subtracted. </p>
  
  <p>I am quite confused here and the answer can't be that hard. </p>
  
  <p>I just want to subtract 5 days from 12/01/2014 to receive 11/27/2014.</p>
  
  <p>Thanks for having a look</p>