Reputation: 1
I am new to writing scripts and I was experimenting. I want to add time stamp along with the string.
const sheet = SpreadsheetApp.openByUrl(SHEET_URL).getSheetByName(
SHEET_NAME
);
const [header] = sheet.getRange('A1:1').getValues();
const STATUS = header.indexOf('Status');
var rowId = Number(e.parameter.row);
var date = new Date()
sheet.getRange(rowId + 1, STATUS + 1).setValue("Data Sent- " + date);
however, all I am getting the Status Column is Data Sent- and no time stamp.
please help where am i going wrong.
Thanks in advance.
Upvotes: 0
Views: 60
Reputation: 324
You should convert the date
to a string
first, like this:
var date = new Date();
var timezone = 'GMC';
var format= 'YYYY-mm-dd';
var formatted_date = Utilities.formatDate(date,timezone , format);
sheet.getRange(rowId + 1, STATUS + 1).setValue("Data Sent- " + formatted_date);
Reference: GAS Utilities Format Date
Upvotes: 2