Update Query, find time difference and update back by Hooks

Hi,
Please find below the Hooks code to find the difference of In and Out and updating it back in the collections. Basically I need the afterUpdate Take Time In and TimeOut and get the Time Difference and update back in the collections using Hooks. Please advise and help me out

Here is the code…
export function LM_Attendance_FL_afterUpdate(item, context) {
let hookContext = context; // see below
let item_at_date = item.fl_at_date;
let item_at_email = item.fl_email;
wixData.query(‘LM_Attendance_FL’).eq(‘fl_email’, item_at_email).eq(‘fl_at_date’, item_at_date)
.find()
.then(result => {
let item = result.items[0];
let Id = result.items[0]._id;
let createddate = result.items[0]._createdDate;
let updatedDate = result.items[0]._updatedDate;
let owner = result.items[0]._owner;
let title = result.items[0].title;
let fl_email = result.items[0].fl_email;
let fl_at_in = result.items[0].fl_at_in;
let fl_at_out = result.items[0].fl_at_out;
let fl_at_date = result.items[0].fl_at_date;
//---- Making the time difference here of In and Out-----
let total_hours = fl_at_out - fl_at_in;
let actual_year = fl_at_out.getFullYear();
let actual_month = fl_at_out.getMonth()+1;
let actual_date = fl_at_out.getDate();
let actual_hours = total_hours.getHours();
let actual_min = total_hours.getMinutes();
let actual_sec = total_hours.getSeconds();
//— Updating the the date and time back
let total_hours_update = new Date(actual_year, actual_month, actual_date, actual_hours, actual_min, actual_sec); //— Does this Work
let fl_at_actual = result.items[0].fl_at_actual;
let fl_at_regfullday = result.items[0].fl_at_regfullday;
let fl_at_regtime = result.items[0].fl_at_regtime;
let fl_at_reg_done = result.items[0].fl_at_reg_done;

let toUpdate = {
“_id”: Id,
“_createdDate”: createddate,
“_updatedDate”: updatedDate,
“_owner”: owner,
“title”: title,
“fl_at_date”: fl_at_date,
“fl_email”: fl_email,
“fl_at_in”: fl_at_in,
“fl_at_out”: fl_at_out,
//— Updating this Variable ----
“fl_at_actual”: total_hours_update,
“fl_at_fullday”: fl_at_regfullday,
“fl_at_regtime”: fl_at_regtime,
“fl_at_reg_done”: fl_at_reg_done
};
wixData.update(“LM_Attendance_FL”, toUpdate)
.then((result) => {
let item = result; //see item below
})
. catch ((err) => {
let errorMsg = err;
});
return item;

}
)}

Here I am not getting the desired result…

Hi I just found. I may be wrong… This database gets populated from afterInsert from LM_Attendance_afterUpdate . After that I am using executing LM_Attendance_FL_afterUpdate. Here it is not getting updated. Is that right.