So I have this cell with a date formatted to only display the month name using MMMM
.
How to use a script in order to format the month name to uppercase while keeping the cell formatted to date? I'm trying to use toUpperCase()
but it's not working.
I'm trying something like:
sheet.getRange(cells[0],1).toUpperCase();
Tried to use also getValues()
in combination with toUpperCase()
but not working either.
Is there another Javascript or GAS method for doing this or am I doing it wrong?
EDIT: I want to store the uppercase month name in the cell and I want the cell to remain in date format not text format.
CodePudding user response:
I do not think there is a formatting option for showing a date in a cell as an uppercase month name.
An alternative to using Apps Script would be to Insert > Column right and use an array formula in row 1 of the new column:
=arrayformula(upper(trim(M1:M)))
The new column would be for viewing only. The date column can remain in place so that you can refer to it in your formulas.
The question specifies Apps Script, so here is how to get the month name in upper case there:
sheet.getRange(cells[0], 1).getDisplayValue().toUpperCase();
There is no way to store this uppercase text string in a cell as a numeric date value.
See Sheets API Date and Number Formats for more info.