I see a bunch of confusing solutions around, and I'm convinced there's a more simple, elegant way.
Right now, "date" would print 11/07. I simply want it to print 11/06.
I've tried subtracting one all over, I understand it's a string now, but I thought I could subtract before I converted it?
Ultimately, I want to hide tabs that contain yesterday's date. The rest of my script works perfectly, just can't figure this part out.
function HideOldTabs(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var allsheets = ss.getSheets();
var date = Utilities.formatDate(new Date(),"EST", "MM/dd")
var data = []
for(var s in allsheets){
var sheet = allsheets[s];
if(
// (sheet.getName() == "Summary") ||
// (sheet.getName() == "Data") ||
// (sheet.getName() == "Sheet1") ||
(sheet.getName().includes(date))
){
sheet.hideSheet();
}
}
return data;
// console.log(date)
}
Most Simple Way to Subtract a Day from DATE in Google Apps Script
, I thought that this thread will be the answer to your question. https://mcmap.net/q/80358/-calculate-the-date-yesterday-in-javascript AboutUltimately, I want to hide tabs that contain yesterday's date.
, I think that when this thread is used, your goal can be achieved. But, in your script,data
is always[]
. So, if you have any other questions, please tell me. If your question is only to retrieve yesterday's date, I will flag it as a duplicated question. – Royal