title: Google Apps Script - deleting a row if today's date is past input date
body: <p>I'd like to make a script that compares the date within a row to today's date and delete that row if today's date is paste the date row. </p>
  
  <p>This is my current script:</p>
  
  <pre><code>    function deleteRow1() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var startRow = 1;  // First row of data to process
  var numRows = sheet.getLastRow()-1;   // Number of rows to process
  var dataRange = sheet.getRange(startRow, 2, numRows);
  // Fetch values for each row in the Range.
  var data = dataRange.getValues();
  
  for (i=0;i&lt;data.length;i++) {
    var row = data[i];
    var date = new Date();
    var sheetDate = new Date(row);
   var Sdate = Utilities.formatDate(date,'GMT+0200','yyyy:MM:dd')
   var SsheetDate = Utilities.formatDate(sheetDate,'GMT+0200', 'yyyy:MM:dd')
          if (Sdate &gt; SsheetDate){
            sheet.deleteRow(i+2) //don't delete header
  }
  }
  }
  </code></pre>
  
  <p>The ultimate goal is to compare dates in column C with today's date and to delete that particular row if today's date is greater.</p>
  
  <p>Right now when I run the script, it deletes some rows, but not specifically the rows that are earlier than today's date.</p>
  
  <p>The beginnings of this script was <a href="https://stackoverflow.com/questions/11025491/google-apps-script-send-email-based-on-date-in-cell">based off another StackOverflow post</a></p>