I'm trying to write a script for my spreadsheet that reads 2 columns (A & B) with A: start date + time and B: end Date + time. The dates are the same day but I get it with the export from the program.
what I'm trying to do with this is gather all the rows that are from the first day of the month, get the start time and from the last row the end time. The Amount of rows per day is dynamic. Per day, the start goes in a cell and the end goes in a cell.
Started with this and got stuck at filtering the values per day:
function hourCalculator()
{
var SSA = SpreadsheetApp.getActiveSpreadsheet(),
sheet = SSA.getSheetByName("Example"),
data = sheet.getDataRange()
.getValues();
for (var i = 1; i < data.length; ++i) {
var day = 1,
maxDay = 32,
row = data[i],
actualSDay = new Date(row[0]),
actualSDateString = Utilities.formatDate(actualSDay, 'Amsterdam', 'dd-MM-yyyy'),
actualSDayNumber = Utilities.formatDate(actualSDay, 'Amsterdam', 'd'),
actualSTimeString = Utilities.formatDate(actualSDay, 'Amsterdam', 'HH:mm'),
actualEDay = new Date(row[1]),
actualEDateString = Utilities.formatDate(actualEDay, 'Amsterdam', 'dd-MM-yyyy'),
actualEDayNumber = Utilities.formatDate(actualEDay, 'Amsterdam', 'd'),
actualETimeString = Utilities.formatDate(actualEDay, 'Amsterdam', 'HH:mm'),
startDayNumber = Number(actualSDayNumber),
endDayNumber = Number(actualEDayNumber),
writeStart = row[6],
writeStop = row[7];
Logger.log(actualSDay);
}
}
=text(A2; "HH:mm")
formula to get the time. – Sangbok Lee