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
code to keep a page Out of the browser history
code to create a new window
sample code to auto focusing the first field in a form
function to combine two or more arrays
how to pass data between pages using Frames
write a code that user can choose/alter Body Text Size
code to sorting an array of objects
how to convert between arrays and strings
code to get the coordinates of a Click Event
advance the focus to next consecutive fields when Enter Key is pressed
code to images to rollover
how to create Expandable and Collapsible Menus
how to pass data between pages using Cookies
Create a Menu that can be activated while clicking on Right Mouse button
snippet to prevent submission of form when certain/any validations got failed