Google Apps Script比較日期問題 - Google

By Hamiltion
at 2020-04-07T11:38
at 2020-04-07T11:38
Table of Contents
請教各位大大
之前小弟在google sheet 做日期計算,沒有什麼問題
A1 2021/01/06
A2 2021/03/30
例如做=A1-A2, 結果是正常的
但最近打算用google apps script運算,發現總是出錯
運算如下:
var ss = SpreadsheetApp.openById('oooooxxxxx');
var SheetName = ss.getSheetByName('sheet');
var range = SheetName.getRange(1,1);
var value = range.getValues();
if(value == 2012/03/21){
Logger.log("Test");
}
後來發現,其實value得到的是
[[Wed Jan 06 00:00:00 GMT+08:00 2021]]
所以無法做運算
請問該怎改,才能正常運算!?
--
之前小弟在google sheet 做日期計算,沒有什麼問題
A1 2021/01/06
A2 2021/03/30
例如做=A1-A2, 結果是正常的
但最近打算用google apps script運算,發現總是出錯
運算如下:
var ss = SpreadsheetApp.openById('oooooxxxxx');
var SheetName = ss.getSheetByName('sheet');
var range = SheetName.getRange(1,1);
var value = range.getValues();
if(value == 2012/03/21){
Logger.log("Test");
}
後來發現,其實value得到的是
[[Wed Jan 06 00:00:00 GMT+08:00 2021]]
所以無法做運算
請問該怎改,才能正常運算!?
--
Tags:
Google
All Comments

By Ophelia
at 2020-04-11T10:31
at 2020-04-11T10:31

By Elvira
at 2020-04-12T01:00
at 2020-04-12T01:00

By William
at 2020-04-15T23:50
at 2020-04-15T23:50

By Bennie
at 2020-04-17T10:09
at 2020-04-17T10:09
Related Posts
Google地圖 iOS App的地圖類型改為預設

By Emily
at 2020-04-07T01:10
at 2020-04-07T01:10
出現'由貴機構管理'不知如何解決

By Damian
at 2020-04-06T21:59
at 2020-04-06T21:59
如何找回google的舊手機資料

By Aaliyah
at 2020-04-05T16:15
at 2020-04-05T16:15
新增至我的雲端硬碟功能

By William
at 2020-04-05T09:00
at 2020-04-05T09:00
google Sheets支援音效?

By Candice
at 2020-04-03T23:05
at 2020-04-03T23:05