I am trying to write a small Google Script which takes data from some cells of Google Sheet and Paste it in the GMAIL. However, while pasting the 'Date Values' it always displays it in the following manner:-
- Mon Apr 15 2019 00:00:00 GMT+0530 (IST)
- Fri Apr 26 2019 00:00:00 GMT+0530 (IST)
But I need the dates in an appropriate way i.e.
- "Mon Apr 15 2019" or
- "Fri 04/26/2019"
I gone through these possible options i.e. Utilities.formatDate & .Split but somehow I am not able to write these codes appropriately. Can you please help me with this matter. Below I have mentioned the entire issue in detail.
My Code
function temp2() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var dataSheet = ss.getSheetByName('Sheet1');
var templateSheet = ss.getSheetByName('Sheet2');
var emailTemplate2 = templateSheet.getRange("G1").getValue();
var rec = templateSheet.getRange("C1").getValue();
var sub = templateSheet.getRange("D1").getValue();
var date = templateSheet.getRange("E1").getValue();
// Logger.log(rec);
MailApp.sendEmail(rec, sub, emailTemplate2);
}
here var date = templateSheet.getRange("E1").getValue(); is the part of code which picks value of date.
Do let me know if you need more details in this regard Regards, Alok