简体   繁体   English

Google工作表脚本可将工作表中的日期添加一周

[英]Google sheet script to add a week to a date from the sheet

Sorry - I'm a newbie! 抱歉-我是新手!

I need to use a script to read a date from a Googlesheet, add a week and save the new date back to the sheet. 我需要使用脚本从Googlesheet中读取日期,添加一周并将新日期保存回该工作表。

I've tried various suggestions from various posts without success. 我尝试过各种帖子中的各种建议,但都没有成功。 The approach I thought should work is failing to get a millisecond value from a date from a cell - subsequent processing appeared OK. 我认为应该工作的方法无法从单元格的日期中获取毫秒值-后续处理似乎正常。

var oldDate  = sheet.getRange('oldDateRange').getValue(); // obtains a date object and then...
var oldDateValue = oldDate.getMilliseconds() // I expected to return milliseconds but shows as undefined...

See link to a simplified illustration sheet and script illustrating my problem. 请参阅指向简化的说明表和脚本的链接 ,以说明我的问题。

This is my first question on StackOverflow - feedback welcome on how to make it more helpful for others.... 这是我对StackOverflow的第一个问题-欢迎反馈如何使它对其他人更有用的信息。

为了将从工作表中获得的日期转换为毫秒,我认为您只需要将.getMilliseconds()替换为.getTime()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM