Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google-apps-script Changing column format

need to format columns c, e and a few others to show the date using the format below:

4 July 2014

Can't work out how to do it ... new to google script!

like image 900
Jaipal Singh Avatar asked Dec 21 '14 12:12

Jaipal Singh


People also ask

What is getRange in App script?

getRange(row, col) : returns a reference to a single cell that is at the intersection of the row and column. The code below returns a reference to the range that is a single cell at the intersection of row 3 and column C. var range = SpreadsheetApp.getActiveSheet().getRange(3,3);

How do I read a CSV file in Google Apps Script?

To view the created files, open the [Apps Script sample] Import CSVs folder in Google Drive. Switch back to the Apps Script project and in the editor, go to the Code.gs file. In the function dropdown, select updateApplicationSheet and click Run.


1 Answers

To do this using Apps script, you can use the setNumberFormat(numberFormat), which lists that date formats follow the SimpleDateFormat specification.

Sample code that will do this:

function formatDate(){
  var ss = SpreadsheetApp.getActive();
  var sheet = ss.getActiveSheet();
  sheet.getRange("A2").setNumberFormat('dd MMM yyyy');
};
like image 66
HDCerberus Avatar answered Oct 26 '22 04:10

HDCerberus