Calculate number of nights between two dates
Calculate number of nights between two dates

Hi,
I'm working on an accomodation table and I would like to autofill by calculation the number of nights between the check-in date and the check-out date.
I've done that but I've got an error. Can somebody help me please ?
{
"data": "check_in_date"
},
{
"data": "check_out_date"
},
{
"data": "number_of_nights",
render: function ( data, type, row ) {
var date1 = New Date (row["check_in_date"]);
var date2 = New Date (row["check_out_date"]);
var time_diff = date2.getTime() - date1.getTime();
var days_Diff = time_diff / (1000 * 3600 * 24);
return (days_Diff);
}
Thanks for your help
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
How about telling us what the error says?
Sorry, my table just keep loading and does not display data
Look in your browser's console for errors. There isn't enough information in the code snippet to help debug. Please post a link to your page or a test case replicating the issue so we can take look.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Sorry,
I just did a little mistake on my code, I wrote New (on "New date") instead of new .
Thank you for your time and your help.
Here is the right code, maybe it could help someone some day :
}