title: Google Scripts automatically add date to column in Google Sheets
body: <p>I am trying to use a Google script that retrieves 2 securities fields from <code>GOOGLEFINANCE</code> and saves the output to a Google Sheet file. I need the script to also add the datetime to the first column of the Sheet.</p>
  
  <p>I have created a basic Google Sheet with 3 columns:</p>
  
  <ol>
  <li>A is formatted to DateTime. It has column name <strong>date</strong> in row 1 and is empty in rows 2 onwards</li>
  <li>C has the column name <strong>price</strong> in row 1 and is empty in rows 2 onwards</li>
  <li>D has the column name <strong>pe</strong> in row 1 and is empty in rows 2 onwards</li>
  </ol>
  
  <p>Here is my function:</p>
  
  <pre><code>function myStocks() {
  
    var sh = SpreadsheetApp.getActiveSpreadsheet();
  
    sh.insertRowAfter(1);
    sh.getRange("A2").setValue(new Date());
  
    sh.getRange("C2").setFormula('=GOOGLEFINANCE("GOOG", "price")');
    sh.getRange("D2").setFormula('=GOOGLEFINANCE("GOOG", "pe")');
  }
  </code></pre>
  
  <p>Here is the output:</p>
  
  <pre><code>Date                    price   pe
  12/10/2017 22:44:31     1037.05 34.55
  12/10/2017 22:43:24     1037.05 34.55
  </code></pre>
  
  <p>The output of columns C and D is correct. The output of column A is wrong. Every time I run the function, each new row is added ABOVE the last row:</p>
  
  <ol>
  <li>The first time I ran the function was at <code>12/10/2017 22:43:24</code> and it added that row first.</li>
  <li>The second time I ran the function was <code>12/10/2017 22:44:31</code> BUT it added that row ABOVE the last row in the sheet - I wanted it to add the new row BELOW the last row.</li>
  </ol>
  
  <p>Is there a way to auto fill the datetime downwards in a single column in GoogleSheets, using a script function?</p>