Google sheets - clear all rows with a date cell having a date older than one week
<p>I'm trying to get a google sheet to hide or delete rows that have a date more than 1 week old in them.</p>

<p>This is what I've managed to piece together.</p>

<pre><code>function ClearOld() {
    var ssActive = SpreadsheetApp.getActiveSpreadsheet();
        SpreadsheetApp.setActiveSheet(getSheetByName('Done'))

    var MyRange = ssActive.getRange("C:C");//selects C column
    var WeekAgo = new Date(date.getTime()-7*(24*3600*1000));
    for(i = 0; i &lt; MyRange.length; i++) {
        if(MyRange[i].getTime()&lt;WeekAgo){
            getActiveSheet().deleteRow(i);
        }
    }
}
</code></pre>