title: How do I get the Formatted Value of a cell using Google Apps Script
body: <p>I want to use Google Apps Script to create a string by concatenating values from a selection of cells within a Google Spreadsheet. The problem is that I won't know whether the cells contain numbers, dates, or text. When the value is a number or date, I want to get the formatted value, the way it is displayed in the spreadsheet.</p>
  
  <p>For example, here is a function that will return the value for a named range.</p>
  
  <pre><code>function getValueByName() {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var theRange = ss.getRangeByName("theNamedRange");
      return theRange.getValue();
  }
  </code></pre>
  
  <p>If the named range contains a date, formatted as 11/6/2013, then this function returns the value as "Wed Nov 06 2013 01:00:00 GMT-0700 (MST)".</p>
  
  <p>I understand that what I am wanting would result in rounding errors for decimal values, but I don't care about that in this case. I just want to get the formatted value.</p>
  
  <p>Thank you.</p>