I'm trying to trigger a function when Date Value in a cell matches today's date, but it's not working. I'm not sure if it has something to do with date format. Any help will be greatly appreciated.
function refreshPage() {
var sheet = SpreadsheetApp.getActive().getSheetByName('1');
var date = sheet.getRange('R2')
var visit = date.getValue();
var today = setValue(new Date(new Date().setHours(0,0,0,0))).setNumberFormat('dd/MM/yyyy');
if(visit == today)
} //run the function
CodePudding user response:
Try it this way:
function refreshPage() {
const sheet = SpreadsheetApp.getActive().getSheetByName('1');
const visit = new Date(sheet.getRange('R2').getValue()).valueOf();
const dt = new Date();
const today = new Date(dt.getFullYear(),dt.getMonth(),dt.getDate()).valueOf()
if (visit >= today) {
//run the func
}
}