I am trying to standardise the formatting of today's date, and date's listed on a google sheet. In order to do this, I have pulled the column's into an array, and am trying to map & slice to get rid of the times on the end of a date. However, the slice is simply returning the first 11 data points. Ie it is not slicing the individual strings, and instead the array as a whole. Any help would be great, as I am very knew to the function.
function getDateColum(){
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Rota")
var dateHeaders = ss.getRange('E3:ND3').getValues();
var date = new Date()
date = date + ""
date = date.slice(0,11)
dateHeaders = dateHeaders.map(function(x){ return x.slice(0,11); })
Logger.log(date)
Logger.log(dateHeaders)
}
Thanks all for your help. This is what ended up working due to the data types, in case anyone sees this later
function getDateColum(){ var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Master Rota") var dateHeaders = ss.getRange('E3:ND3').getValues(); var date = new Date() date = date + "" date = date.slice(0,11) dateHeaders = dateHeaders[0].map(function(x){ return x.toString().substring(0, 11) }) Logger.log(dateHeaders) Logger.log(date)
Thanks again
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.