The problem
I have a Google form that is correctly logging data into a Google Sheet. However the format of the date when logged to Google Sheet is DD/MM/YYYY.
Desired outcome
To format the date as MM/DD/YYYY whenever a new form submission is made (So whenever a new row is created).
What I have so far
A working form which logs the date
There is the ability to run a script when a form trigger is made. Heres what I have so far for my app script:
Code.gs
function respondToFormSubmit() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Format column I
var column = sheet.getRange("B:B");
// Set new date format on column I
column.setNumberFormat('mm/dd/yyyy');
};
Current error I'm getting
TypeError: Cannot call method "getSheets" of null.
I'm not sure why its returning null
as the current script is correctly linked to the Google Form.
How can I get to my desired outcome where column B has a date format of MM/DD/YYYY when a new form submission is made?