https://docs.google.com/spreadsheets/d/11O3eWzuvwO4qeXbciVoibhR2ZRwIIEXqizOqcs8rqoI/edit?usp=sharing
this is what i've got so far but its missing some months and not hiding the 30 & 31 days of the month.
,,,,
,,,,
function hideDates()
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName("UI Data");
var v = s.getRange("C:C").getValues();
for (var i = s.getLastRow(); i > 2; i--)
{
var t = v[i - 0];
if (t != "")
{
var u = new Date(t);
var dateToday = 1;
var testDate = u.getDate();
if (t >"")
if (dateToday != testDate)
{
s.hideRows(i);
}
}
}
}
CodePudding user response:
In your Spreadsheet, it seems that the value of column "C" is like 01/02/2022 00:00:00
. If this format is constant, as a simple method, how about retrieving the values as the string value? When this is reflected in your script, it becomes as follows.
Modified script:
function hideDates() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName("UI Data");
var v = s.getRange("C:C").getDisplayValues();
v.forEach(([c], i) => {
if (Number(c.split("/")[0]) != 1) {
s.hideRows(i 1);
}
});
}
- In this modification, the value like
01/02/2022 00:00:00
is retrieved as the string value, and01
is retrieved as the number, and then,hideRows
is run by comparing it with1
.