我的查询与this Google Form responses spreadsheet有关。我试图调整我从here获得的脚本。
function cleanup() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Form responses 1');
var values = sheet.getDataRange().getValues();
var InAYear = (Date.now()/86400000 + 25569) + 365;
for (var i = values.length - 1; i >= 0; i--) {
if ( values[i][5] >= InAYear) {
sheet.deleteRow(i+1);
}
}
}

我试图将此表格与工作表的“开始日期”列中的日期与一年中的日期进行比较,如果列条目大于此值,则删除该行(即,如果日期在床单上提前一年多)。但是,我显然不明白如何以相同的格式获取两个不同的日期,因为在调试时检查变量值会显示截然不同的值。
答案 0 :(得分:1)
尝试以下脚本代码:
.$_GET['txtMail']."' AND Password = '".$_GET['txtPass']."'";
^^^^^^^^^ ^^^^^^^^^
答案 1 :(得分:0)
看起来我有它工作,并给我发电子邮件。
function cleanup(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Form responses 1');
var values = sheet.getDataRange().getValues();
var today = new Date();
var InAYear = new Date();
InAYear.setFullYear( today.getFullYear()+1 );
var emailaddress = "****";
var subject = "Annual Leave Request";
var message = "Annual Leave has been requested as follows:" + "\n\n";
for (var i = values.length - 1; i >= 0; i--) {
if ( values[i][4] > InAYear ) {
sheet.deleteRow(i+1);
subject = "Annual Leave Request - Rejected";
message = "The following annual leave request was rejected due to being more than one year in advance:" + "\n\n";
}
}
for(var field in e.namedValues) {
message += field + ':'
+ "\n" + e.namedValues[field].toString() + "\n\n";
}
MailApp.sendEmail(emailaddress, subject, message);
}
感谢Kishan,没有谁的帮助,我无法进入这个阶段。