Created
January 25, 2022 23:11
-
-
Save richashworth/5ea4cc5960cceb98b8313f393fd0a508 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MILLIS_PER_DAY = 1000*60*60*24 | |
const HEADER_ROWS = 1 | |
function hide() { | |
const ss = SpreadsheetApp.getActiveSpreadsheet() | |
const sheet = ss.getSheets()[0] | |
const dateCol = sheet.getRange("A:A").getValues().map(function(row) { | |
return row[0] | |
}) | |
var i = HEADER_ROWS | |
while (_daysBetween(dateCol[i], Date.now()) > 20) { | |
i++ | |
} | |
sheet.hideRows(HEADER_ROWS + 1, i) | |
} | |
function _daysBetween(date1, date2){ | |
return Math.floor((date2 - date1) / MILLIS_PER_DAY) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment