In that case this is very much a JavaScript question and not a Struts one. I can tell you that the JavaScript Date functions are terrible. You could adapt my previous technique as follows:

1) Create a variable for holding the total
2) Create a Date object form both the start and end dates.
3) Convert these to JS Time Stamps (there is a JS function for this in the Date object), a JS time stamp is the number of milliseconds since Jan 1 1970.
4) Run a loop like:
for(var x = startTimeStamp;x<endTimeStamp;x+=86400000) { //86400000 is the number of MilliSeconds in a day
  //create a JS Date object for the current day we are checking (x)
  // then do the same as with the Java sudo code I posted before
}

Abhimanyu Koul wrote:
thanks.
but i am really looking for a way to do this on the client side.
any idea?

Abhimanyu Koul
FinEng Solutions (P)  Ltd.
Dani Compound,
158, Vidyanagari Marg,
Kalina, Santacruz (East),
Mumbai - 400 098
Mobile : +91 9860582533
----- Original Message -----
From: "Bart Busschots" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Thursday, May 25, 2006 5:34 PM
Subject: Re: number of days


This isn't a struts question but anyway, assuming you want to do this on
the server side and not on the client side (you'd be mad to do it on the
client side) the java Date related utility classes will be able to help
you out (java.util.Calendar, java.util.GregorialCalendar, java.util.Date).

The way I would do it would be something like this:
1) Create a counter to hold your total
2) Create a date for your start time and for your end time
3) Convert the date for your start time to a Calendar
Write a while loop something like:

while(startDate.before(EndDate)){
   if(startDate is a Sunday){
       ; file://do nothing
   }if(startDate is a Saturday){
      total += 0.5;
   }else{
      total += 1.0;
   }
   file://add a day to the Start Date
}

HTH, Bart.

Abhimanyu Koul wrote:
hi!
i am really struggling to find a  way to calculate number of days
between two dates in mm/dd/yyyy which i get using javascript popup
calendars.  excluding sundays and half saturdays.
the number of days i have to record in the database.
please help

Abhimanyu Koul
FinEng Solutions (P)  Ltd.
Dani Compound,
158, Vidyanagari Marg,
Kalina, Santacruz (East),
Mumbai - 400 098
Mobile : +91 9860582533


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to