title: set date as sheet name in Spreadsheet
body: <p>I'm trying to rename a newly created sheet with yesterday's date, and in some cases with the date 14 days ago. Here's what I've got so far. </p>
  
  <p>I found this snippet here on Stackoverflow and modified it a little to suit my purpose. However, this produces the sheet to be named with today's date. </p>
  
  <pre><code>// previous lines have been left out
  // set sheet name to yesterday's date
  
  var eet = ss.getSpreadsheetTimeZone();
  var sheets = ss.getSheets();
  var date = Utilities.formatDate(new Date(), eet, 'yyyy-MM-dd');
  //this returns today's date (need yesterday's date, or date from 14 days ago)
  
  sheets[1].setName(date);  // Rename second sheet
  </code></pre>
  
  <p>I hope you guys can help </p>