Mylene Posted June 21, 2016 Report Share Posted June 21, 2016 Hi, I'd like to know how much time user spends on updating record on the details datapage. So I need to stamp record when user opens the record, then when he updates the record and store the time difference in minutes. Thanks for help! Quote Link to comment Share on other sites More sharing options...
Mathilda Posted June 21, 2016 Report Share Posted June 21, 2016 Hi Mylene, Add header/footer to your datapage and in the footer try using the following script: <SCRIPT LANGUAGE="JavaScript"> window.addEventListener("load", myfunction1); document.getElementById("caspioform").addEventListener("submit", myfunction); document.getElementById("caspioform").addEventListener("submit", getDiff); function myfunction1() { Stamp = new Date(); var v_TimeStamp; Hours = Stamp.getHours() Mins = Stamp.getMinutes(); if (Mins < 10) { Mins = "0" + Mins; } v_TimeStamp=('' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+Stamp.getFullYear() + ' ' + Hours + ":" + Mins); document.getElementById("EditRecordStart_Date").value=v_TimeStamp; } function myfunction() { Stamp = new Date(); var v_TimeStamp; Hours = Stamp.getHours() Mins = Stamp.getMinutes(); if (Mins < 10) { Mins = "0" + Mins; } v_TimeStamp=('' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+Stamp.getFullYear() + ' ' + Hours + ":" + Mins); document.getElementById("EditRecordEnd_Date").value=v_TimeStamp; } function getDiff() { var v_sDate = document.getElementById("EditRecordStart_Date").value; var v_eDate = document.getElementById("EditRecordEnd_Date").value; var sDate = new Date(v_sDate); var eDate = new Date(v_eDate); var timeDiff = Math.abs(eDate.getTime() - sDate.getTime()); var diffDays = Math.ceil(timeDiff / (1000 * 3600)); document.getElementById("EditRecordDifference").value=diffDays; } </SCRIPT> Replace "Start_Date" with your field name of the field for date, when user opens the record Replace "End_Date" with your field name of the field for date, when user updates the record Replace "Difference" with your field name of the field for time difference Quote Link to comment Share on other sites More sharing options...
Aether Posted December 4, 2018 Report Share Posted December 4, 2018 Hi @Mylene, You can now stamp the time on DataPages without having JavaScripts. You may visit this link. I hope this helps ~WatashiwaJin~ Quote Link to comment Share on other sites More sharing options...
DefinitelyNot31337 Posted June 27, 2019 Report Share Posted June 27, 2019 Hello @Mylene, In addition to @WatashiwaJin's answer, you would need to have two Date/Time fields and one optional formula field on your table to calculate the time they spend populating it (i.e. from when the page was loaded, to when the form was submitted). For the time_start field, you may do an (Advanced) > OnLoad > Timestamp For the time_end field, DO make sure that the timestamp is selected on the Form Element: setting. As for calculating the time in between, you may define a Formula Formula field in your table that has the syntax of: DATEDIFF( hour, [@field:time_start], [@field:time_end] ) More information about formula fields: https://howto.caspio.com/tables-and-views/data-types/formula-fields/ Function Reference: https://howto.caspio.com/function-reference/ Hope this helps. -DN31337! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.