Google-sheets – sheet name from cell (formatting issue)

google sheetsgoogle-apps-script

I have been tasked with creating reservation sheets for a restaurant. The sheets are for internal use only so the only people with access to these sheets are the staff in the reception, reservations and marketing.

That said, it's a time consuming task to edit these sheets and make sure the data is correct. The idea is to have one workbook for each month of the year and then one sheet each per day of the month.

The request is to have the sheets be named in the following manner:
enter image description here

The red marking for Sundays is entirely optional unless there is an easy way to implement this.

I am not an expert at scripting but I have spent several hours trying to find a solution to this. The closest I've come so far is the script below:

function onEdit(e) {
if(e.range.getA1Notation() !== 'C1') return;
    var s = e.source.getActiveSheet()
            s.setName(s.getRange('C1')
                .getValue())
}

The function works in as much as it changes the name of the sheet, however, the format of the name of the sheet shows up in the following way:

Fri May 01 2020 00:00:00 GMT+0100 (BST)

I'm sure there is a way to specify the format of the name displayed, I just can't figure it out myself.

Desired format:

Fri 01 May

All help appreciated.

Best Answer

Issue resolved.

Instead of formatting the cell as a date, I formatted it as plain text as suggested above and then in the cell I used the following formula:

=TEXT(Date!A24,"ddd dd mmmm")

Thank you.