code to calculate the number of days between two dates
Answers were Sorted based on User's Feedback
Answer / nikhil
<script language="javascript">
Date.prototype.DaysBetween = function()
{
var intMilDay = 24 * 60 * 60 * 1000;
var intMilDif = arguments[0] - this;
var intDays = Math.floor(intMilDif/intMilDay);
return intDays;
}
var d1 = new Date("06/01/2008");
var d2 = new Date("07/31/2008");
alert(d1.DaysBetween(d2));
var d3=d1.DaysBetween(d2);
document.write(d3);
</script>
Is This Answer Correct ? | 8 Yes | 6 No |
Answer / 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 |
code to detect availability of cookies
could you please tell me for what javac, javax,swing,awt.*; are using. what is the meaning and differences. and also there are 4 access modifiers in java. public, private, protected, default. what is the meaning of these 4 access modifiers and difference. public is the access modifier void means return data type disp() means function name what mean by static
How to encode and decode URL strings?
how to Scroll a DIV content
code to keep a page Out of the browser history
code to get the coordinates of a Click Event
determine which key was pressed and its type
how to transform XML Data into HTML
write a code to generate pseudorandom numbes
code to positioning of window in certain dimensions
how to copy form data between different pages
how to convert between arrays and strings