Created
January 6, 2015 09:17
-
-
Save umjammer/cafbc1286093e3706258 to your computer and use it in GitHub Desktop.
coloring sunday and saturday on datetime columns on google spreadsheet
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
/** | |
*/ | |
function colorRows() { | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
var rows = sheet.getDataRange(); | |
var numRows = rows.getNumRows(); | |
var range = sheet.getRange(2, 1, sheet.getLastRow()); | |
var check = range.getValues(); | |
for (var i = 1; i < numRows - 2; i++) { | |
var weekday = (((new Date(check[i][0]).getDay()) + 6) % 7) + 1; | |
Logger.log(weekday); | |
if (weekday == 6) { | |
sheet.getRange(i + 1, 1).setBackground("#ccccff"); | |
} else if (weekday == 7) { | |
sheet.getRange(i + 1, 1).setBackground("#ffcccc"); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment