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
determine which Element received an Event
how to create a Custom Scrollbar
how to create Expandable and Collapsible Menus
code to keep a page Out of the browser history
write a code to generate pseudorandom numbes
code to sorting an array of objects
code to positioning of window in certain dimensions
how to pass data between pages using Frames
maximizing the main window
code to create a new window
how to create a Draggable element
how to create an anonymous function
snippet to prevent submission of form when certain/any validations got failed
program to bring a window to the front
how to copy form data between different pages