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.
This is my current script:
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<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 > SsheetDate){
sheet.deleteRow(i+2) //don't delete header
}
}
}
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.
Right now when I run the script, it deletes some rows, but not specifically the rows that are earlier than today's date.
The beginnings of this script was based off another StackOverflow post