在Google Apps脚本中比较范围到今天的日期 [英] Comparing dates from range to today's date in Google Apps Script

查看:253
本文介绍了在Google Apps脚本中比较范围到今天的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望比较从电子表格拉到日期的日期,使用这篇文章作为参考:如何使用Google Apps脚本将日期与电子表格进行比较?

I'm looking to compare dates pulled from a spreadsheet to today's date, using this post as a reference: How do I compare dates with a spreadsheet using Google Apps Script?

我运行脚本,在对象'message中找不到函数getTime(),声明var dataDay(for循环之后的第一行)。

When I run the script, I get a 'Cannot find function getTime() in object' message for the line that declares var dataDay (first line after for loop).

当我运行调试器时,位置值[i] [18]中的值虽然说是一个日期对象。任何想法在这里?

When I run the debugger, the values in the position values[i][18] though say it is a date object. Any thoughts here?

function gantChart() { 
  var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Copy of 2016 Gift Tracking");
  var values = ss.getRange(3,1,ss.getLastRow(),ss.getLastColumn()).getValues();
  var day = 24*3600*1000
  var today = parseInt((new Date().setHours(0,0,0,0))/day);
  var destSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Get chart automation");
  for (var i=0; i < values.length; i++) {
    var dataDay = parseInt(values[i][18].getTime()/day);
    if(dataDay > today) {
     }
  } 
  debugger;
}


推荐答案

评论由Serge insas

From a comment by Serge insas


尝试用新的日期替换值[i] [18](值[i] [18])

这篇关于在Google Apps脚本中比较范围到今天的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆