I need to get the difference between two dates in days.
Up to now, I've been able to get the difference between two dates, but not in days:
date1.getTime() - date2.getTime();
Any ideas?
Calculate the no. of days between two dates, divide the time difference of both the dates by no. of milliseconds in a day (1000*60*60*24) Print the final result using document.
Call the getTime() method on each date to get a timestamp. Compare the timestamp of the dates. If a date's timestamp is greater than another's, then that date comes after.
To calculate the difference between two dates in the same column, we use the createdDate column of the registration table and apply the DATEDIFF function on that column. To find the difference between two dates in the same column, we need two dates from the same column.
var diff = Math.abs(date1.getTime() - date2.getTime()); var diffDays = Math.ceil(diff / (1000 * 3600 * 24));
I believe the shortest route is:
var diff = date1.valueOf() - date2.valueOf();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With