"MMMM yy"-date in google spreadsheet

Clox picture Clox · Nov 21, 2011 · Viewed 42.9k times · Source

I have a google spreadsheet in which I want a date with only the name of the month and the year, like September 2011, and I also want the month and year to be easily changeable. Is there any way of getting custom date formats to do this?

I figured out I could do like this:

=TEXT(40295; "MMMM yy")

But then the datepicker can't be used anymore and changing the date is made impossibly hard.. Is there any good way of solving this?

Answer

Henrique G. Abreu picture Henrique G. Abreu · Dec 1, 2011

You can set a custom format to a cell using Google Apps Script.
Open the script editor (menu Tools > Script editor), paste this, save and Run > onOpen.

function onOpen() {
  SpreadsheetApp.getActive().addMenu(
    'Format', [{name:'Custom', functionName:'customFormat'}]);
}

function customFormat() {
  var format = Browser.inputBox('Write the format to be applied on the seleted cells');
  if( format !== 'cancel' )
    SpreadsheetApp.getActiveRange().setNumberFormat(format);
}

On your spreadsheet a new menu should appear in the end where you can pick the Custom entry to enter your custom format for the selected cells.