title: filter columns script google sheets
body: <p>Below is the script I am using to hide sheets and filter visible area.  I am attempting to filter the column that contains the current date and only show cell rows with text in that column. The filter should only be active between 9 and 10 am.  Any thoughts? </p>
  
  <pre><code>function onEdit(e) {
  var sheet = e.source.getSheetByName('Sheet1'); // or .getSheets()[0]; to apply to the first sheet.
  var dates = sheet.getRange(1, 4, 1, sheet.getLastColumn() - 1).getValues()[0];
  var today = Date.now()
  var n = d.getHours();
  
  if (n &gt;= 9 &amp;&amp; n &lt;= 10){
     filterSettings.range = {
      sheetId: ss.getActiveSheet().getSheetId()
    };
  
    filterSettings.criteria = {};
    var columnIndex = "column with today's date";
    filterSettings['criteria'][columnIndex] = {
      'not null' : condition_value
    };
   } else { 
       var ss = SpreadsheetApp.getActiveSpreadsheet();
       var ssId = ss.getId();
  
       var dataSheet = ss.getActiveSheet();
       var lastRow = dataSheet.getLastRow();
       var lastColumn = dataSheet.getLastColumn();
       var sheetId = dataSheet.getSheetId();
  
       var filterSettings = {
         "range": {
           "sheetId": sheetId,
           "startRowIndex": 0,
           "endRowIndex": lastRow,
           "startColumnIndex": 0,
           "endColumnIndex": lastColumn
         }
       };
   var requests = [{
     "setBasicFilter": {
       "filter": filterSettings
   }
  }];
   Sheets.Spreadsheets.batchUpdate({'requests': requests}, ssId);
  }
  </code></pre>