code to calculate the number of days between two dates
Answer Posted / nagaraj
function getDaysMinusWeekend(startDay, startMonth,
startYear, endDay, endMonth, endYear) { var sdate = new Date
(); var edate = new Date(); var odays = 0; var total =
0; sdate.setFullYear(startYear,startMonth,startDay);
edate.setFullYear(endYear,endMonth,endDay);
odays = 6 - sdate.getDay(); if(odays == 6) {
odays = 0; } sdate.setFullYear
(startYear,startMonth,startDay + odays); return
Math.floor(((((edate.getTime() - sdate.getTime()) / 1000 /
60 / 60 / 24) / 7) * 5) + odays);}// ########## startMonth
and endMonth both start at 0 i.e 0 = january, 1 = feb etc
function getDaysMinusWeekend(startDay, startMonth,
startYear, endDay, endMonth, endYear) {
var sdate = new Date();
var edate = new Date();
var odays = 0;
var total = 0;
sdate.setFullYear(startYear,startMonth,startDay);
edate.setFullYear(endYear,endMonth,endDay);
odays = 6 - sdate.getDay();
if(odays == 6) {
odays = 0;
}
sdate.setFullYear(startYear,startMonth,startDay +
odays);
return Math.floor(((((edate.getTime() -
sdate.getTime()) / 1000 / 60 / 60 / 24) / 7) * 5) +
odays);
}
| Is This Answer Correct ? | 4 Yes | 6 No |
Post New Answer View All Answers
program to bring a window to the front
Create a Menu that can be activated while clicking on Right Mouse button
code to create a new window
create Drop-Down Navigation Menus
write a code to generate pseudorandom numbes
code to detect availability of cookies
how to convert between arrays and strings
how to copy form data between different pages
Code to Block submission of form by pressing Enter Key
how to get the User's Time of Day
snippet to prevent submission of form when certain/any validations got failed
code to get the coordinates of a Click Event
How to encode and decode URL strings?
code to keep a page Out of the browser history
advance the focus to next consecutive fields when Enter Key is pressed