gpt4 book ai didi

google-apps-script - 在对象 33463 中找不到函数 getMonth

转载 作者:行者123 更新时间:2023-12-01 11:23:10 25 4
gpt4 key购买 nike

我已经创建了一个脚本来向特定的人发送带有生日提醒的电子邮件。这一直工作到前天。我不知道为什么会出现找不到函数 getMonth 的错误,谁能告诉我错误在哪里

function emailAlert() {

// Short circuit if email notice is set to "No". This causes an error and the script stops.
if (turnOnEmailNotice.toLowerCase() == "no")
{
Logger.log("The Email Notification is NOT turned ON. System will Exit.");
exit
}

//Get the total number of filled row in the sheet.
var currentRowAT = 2;
var currentCellValueAT = "start";
while (currentCellValueAT != ""){
if (currentCellValueAT = birthdaysSheet.getRange("G" + currentRowAT).getValue() != ""){
currentRowAT = currentRowAT +1;
}
}
var birthdaysSheetLastRow = currentRowAT - 1;

// Get today's Date (with Month, Date and Year)
var today = new Date();
var todayMth = today.getMonth()+1;
var todayDate = today.getDate();
var todayYear = today.getFullYear();


// Check sheet cell for match to alertDate, k is the current row number being checked. Starting at 2 as the row #1 is for the headers
for (k=2; k < birthdaysSheetLastRow + 1; k++)
{
var targetBday = new Date();
targetBday = birthdaysSheet.getRange("P" + k).getValue();

// If Birthday is not speicified, continue with the next row
if (targetBday == ""){continue};

var unadjTargetBday = new Date();
var unadjTargetBdayMth = targetBday.getMonth()+1;
var unadjTargetBdayDate = targetBday.getDate();
var unadjTargetBdayYear = targetBday.getFullYear();
var unadjTargetBday = targetBday;


targetBday.setDate(targetBday.getDate()-daysInAdvance); // Calculating how many days in advance you want to trigger the notification. This is set in Settings Tab.
var targetBdayMth = targetBday.getMonth()+1;
var targetBdayDate = targetBday.getDate();

if (targetBdayMth + " " + targetBdayDate == todayMth + " " + todayDate)
{
var targetBirthDateYearsOld = (today.getYear() - unadjTargetBday.getYear())-1900;
prepareAndSendEmail(k, targetBirthDateYearsOld);
}
}
}

最佳答案

getValue 将根据电子表格中的单元格类型返回字符串/日期/数字类型(请参阅菜单格式 -> 数字)。可以肯定的是,总是转换为日期类型。这是转换它的正确方法:

var targetBday = new Date(birthdaysSheet.getRange("P" + k).getValue());

关于google-apps-script - 在对象 33463 中找不到函数 getMonth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39978160/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com