Answer the question
In order to leave comments, you need to log in
How to calculate time difference between two cells?
I am very superficially familiar with programming on Google apps script, based on my knowledge I wrote the following code (I’ll say right away that it doesn’t work correctly):
function ResponseTime(){
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var sheetName = SpreadsheetApp.getActiveSpreadsheet().getSheetName();
var range = sheet.getActiveRange();
var data = range.getValues();
if(sheetName == "Вопросник" && range.getColumn() == 17){
for (var i=0;i < data.length;i++){
if (data[i][0]>0) {
(data[i][0])=Date.parse(data[i][0]);
var time1 = (data[i][0])}
else {
}
}
}
if(sheetName == "Вопросник" && range.getColumn() == 18){
for (var i=0;i < data.length;i++){
if (data[i][0]>0) {
(data[i][0])=Date.parse(data[i][0]);
var time2 = (data[i][0])}
else {
}
}
for (var i=0;i < data.length;i++){
if (data[i][0]>0 && time2>0) {
let date = new Date(time2);
range.offset(i,+1,1,1).setValue(date.getHours()+':'+date.getMinutes());}
else {
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Everything has already been thought of. https://support.google.com/docs/answer/6055612
Can you make it easier with formulas? The difference between the dates is a direct specific difference, because dates is the number of days since a particular date.
Describe in words - what needs to be done? And attach a sign - it will speed up the decision.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question