Skip to content

Instantly share code, notes, and snippets.

@richashworth
Created January 25, 2022 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richashworth/5ea4cc5960cceb98b8313f393fd0a508 to your computer and use it in GitHub Desktop.
Save richashworth/5ea4cc5960cceb98b8313f393fd0a508 to your computer and use it in GitHub Desktop.
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