Brain teaser

1. Senior Member
Join Date
Dec 1969
Posts
154

## Brain teaser

hi everybody<BR><BR>this may not be a brain teaser to most of you people as it is to me.What i&#039ve got is two sets of dates one the start date and the other the end date of vacation for an emp.when this person fills out both which may span months,i&#039ve got to calculate the no of days between these two dates and then deduct the no of saturdays and sundays and u.s. national holidays from the leave period and print the effective no of working days the person has actually applied for leave . ideas pls.thanx

2. Luc
Member
Join Date
Dec 1969
Posts
52

## RE: Brain teaser

Maybe this can help:<BR><BR>&#060;script language="VBScript"&#062;<BR> &#060;!--<BR> Dim BeginDate,EndDate,Date,nDays <BR> <BR> Date = BeginDate<BR> <BR> Do while DateDiff("y",Date,EindDatum) &#062;= 0 <BR> Dag = WeekDay(Date)<BR> If (Dag &#060;&#062; 1) AND (Dag &#060;&#062; 7) then <BR> nDays = nDays + 1<BR> End if<BR> Date = DateAdd("y",1,Datum)<BR> Loop<BR> --&#062;<BR> &#060;/script&#062;<BR><BR><BR>This loop calculates the days between 2 dates and leaves out the saterdays en sundays<BR>I hope this is wat you were looking for<BR>

3. jd
Senior Member
Join Date
Dec 1969
Posts
850

## RE: Brain teaser

You would need to keep a table of holiday dates, first. Here is a quickie algorithm for determining number of weekdays between two dates. You will have to insert your own check for holidays...<BR><BR>Assuming that dtStart is the start date, and dtEnd is the end date (also assumes that dtStart is less than dtEnd). Yhis is not tested, just winging it, but should work:<BR><BR>dtTemp = dtStart<BR>while DateDiff("d", dtTemp, dtEnd) = 0<BR>&nbsp;&nbsp;&nbsp; lngWeekDay = weekday(dtTemp)<BR>&nbsp;&nbsp;&nbsp; if lngWeekDay &#060;&#062; vbSaturday and lngWeekDay &#060;&#062; vbSunday then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039 Here you would also insert your check for holidays<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lngVacDays = lngVacDays + 1<BR>&nbsp;&nbsp;&nbsp; end if<BR>&nbsp;&nbsp;&nbsp; dtTemp = DateAdd("d", 1, dtTemp)<BR>wend<BR>

4. sr
Member
Join Date
Dec 1969
Posts
55

## RE: Brain teaser

Hi<BR>I like to know in JScript

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•