increment a cell in google sheets each day

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


increment a cell in google sheets each day



I have a script that needs to increment a cell every day. I have tried several methods comparing dates with the current date with the previous recorded date but that doesn't seem to work at all.



I am recording the day each time there is an entry, which I was using to increment the cell, with the following


var curDate = Utilities.formatDate(new Date(), "GMT-5", "MM/dd/yyyy")



the last thing I did to compare them was the following:


var today = parseInt(Utilities.formatDate(new Date(),"EST","D"));
var lastRecordedDay = parseInt(Utilities.formatDate(new Date(SpreadsheetApp.getActiveSpreadsheet().getSheetByName("total").getRange(challegeDay,3).getValues()),"EST","D"));

if (SpreadsheetApp.getActiveSpreadsheet().getSheetByName("total").getRange(challegeDay,3) < curDate.valueOf() ){
}



but the output told me yesterday had a bigger number than today, which should not be the case.





Have you done any research on how to compare Dates in Javascript? There are some great questions & answers here on Stack Overflow. Also consider the difference in the returned object between Range#getValue() and Range#getValues(). You will probably benefit a lot from breaking up your one-liners into manageable chunks - a common approach taken when performing basic script debugging.
– tehhowch
10 mins ago




Date


Range#getValue()


Range#getValues()









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived