0

I want to compare the date that was created in the spreadsheet with a specific date.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var spreaddate = ss.getSheetByName("sheet123").getRange("B2").getValue();
//--> Thu Dec 12 00:00:00 GMT+09:00 2019
var comparedate = new date(yyyy-mm-dd)//somting like this
if(spreaddate > comparedate){
do something
}

The spreaddate is not recognized as a date. Even if I try to convert it to a date, it's hard because it's written in letters, not numbers like Thu Dec. What should I do?

2
  • If the output of spreaddate is "Thu Dec 12 00:00:00 GMT+09:00 2019", then it's probably a date. Your declaration of comparedate looks wrong, though. What's the exact error you're receiving? Commented Jan 24, 2020 at 7:14
  • Diego It's good to try again. I made a wrong date for the comparison. Thank you. Commented Jan 24, 2020 at 7:44

1 Answer 1

1

I think the problem is that you're not correctly defining your comparedate. You need to use a capital 'D' new Date().

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.