我正在尝试使用 Apps 脚本比较 Google Docs 中的两个日期。我的日期格式为 m/d/yyyy h:mm:ss。我不断收到一条错误消息,提示“无法在对象 2/1/2013 9:42:46 中找到函数 getTime。” 我的日期格式有问题吗?我之前成功地将它用于格式为 mm/dd/yyyy 的日期,但不确定为什么添加时间戳会有所不同。任何帮助将不胜感激!
for (var i = 0; i < kValues.length; i++) { // repeat loop
if (kValues[i][0] == "") {var lastupdate = parseInt(new Date("1/1/1980 00:00:00").getTime()/day); } // if a date doesn't exist, throw it back in the past
if (kValues[i][0] != ""){
var lastupdate = parseInt(kValues[i][0].getTime()/day);} // if a date does exist, interpret it. Here's where I'm getting my error.
var statusDateChange = parseInt(statusDate[i][0].getTime()/day); // interpret a date from Sheet 2
var statusChange = changeStatus[i][0]; //find the new status
var currentStatus = status[i][0]; //find the old status
var currentOID = oid[i][0]; // set Order ID
var changeOID = statusOID[i][0]; // set Order ID in Sheet 2 to compare
Logger.log(lastupdate + "<=" + statusDateChange);
if (lastupdate <= statusDateChange && currentOID == changeOID && statusChange != currentStatus) {sheet.getRange(i + 2, 8, 1, 1).setValues(statusChange); // if the date in Sheet 1 is less than the date in Sheet 2 and the ID matches, change the status
}
}