I am calculating the number of days between the 'from' and 'to' date. For example, if the from date is 13/04/2010 and the to date is 15/04/2010 the result should be
How do I get the result using JavaScript?
To find the number of days between these two dates, you can enter “=B2-B1” (without the quotes into cell B3). Once you hit enter, Excel will automatically calculate the number of days between the two dates entered. Note that Excel recognizes leap years.
The Excel NETWORKDAYS function calculates the number of working days between two dates. NETWORKDAYS automatically excludes weekends (Saturday and Sunday) and can optionally exclude a list of holidays supplied as dates.
const oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds const firstDate = new Date(2008, 1, 12); const secondDate = new Date(2008, 1, 22); const diffDays = Math.round(Math.abs((firstDate - secondDate) / oneDay));
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