I can't figure out how to calculate the duration in a start-date to end-date. Once Calendar options are selected, you have the option for stat and end dates, I ned an auto calculation to workout the duration.
Any ideas?
Thanks
I can't figure out how to calculate the duration in a start-date to end-date. Once Calendar options are selected, you have the option for stat and end dates, I ned an auto calculation to workout the duration.
Any ideas?
Thanks
$(document).on('knack-view-render.view_29', function(event, view, data) {
document.getElementById("field_63").readOnly = true;
$(document).on("change load input click", "#kn-input-field_60 input", function(){
var startDate = $("#view_29-field_60").val().split("/");
var endDate = $("#view_29-field_60-to").val().split("/");
console.log(startDate[2]+"/"+startDate[1]+"/"+startDate[0]);
startDate = new Date(startDate[2],startDate[1],startDate[0]);
endDate = new Date(endDate[2],endDate[1],endDate[0]);
var timeDiff = Math.abs(endDate.getTime() - startDate.getTime());
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
console.log(diffDays);
$("#field_63").val(diffDays);
});
});
Here's how I did it to output the number of days into a new field, just replace the views and fields as necessary, not really optimized at all but functioning
Same problem.
I need to calculate the duration of calendar events...