You can subtract two dates and get a number. You will probably have
to divide by something and use @Integer--I'd guess the number of
seconds in a day to get elapsed days, divide by 7 to get number of
weeks. You can use @Weekday to get back a number for the day of the
week for each date. Seems like this should be enough to figure out
how many weekend days there were. Holidays could be a problem,
especially if you need to cover more than one country.
Sounds messy but possible.
Regards,
Jim
jimj...@mcs.net
http://www.mcs.net/~jimjoyce/
That not include holiday days,
Soory for my english
diffDays := (EndDate - StartDate) / 86400 + 1;
strtDay := @Modulo(@Weekday(StartDate); 7);
endDay := @Modulo(@Weekday(EndDate); 7);
result := (diffDays - endDay + strtDay - 8) * 5 / 7 - @Max(-2; -strtDay) -
@Min(1; endDay) + 5 - strtDay + endDay;
@If (StartDate != "" & EndDate != ""; result; 0)
Lee Tankersley <ltank...@worldnet.att.net> a écrit dans l'article
<6i3go7$4...@bgtnsc03.worldnet.att.net>...
diffDays := (EndDate - StartDate) / 86400 + 1;
strtDay := @Modulo(@Weekday(StartDate); 7);
endDay := @Modulo(@Weekday(EndDate); 7);
result := (diffDays - endDay + strtDay - 8) * 5 / 7 - @Max(-2; -strtDay) -
@Min(1; endDay) + 5 - strtDay + endDay
Hope that helps.........
Abdul Haque.
The first 'compound formula' does this - there are hundereds of other
useful examples.
Gerry King
<URL:mailto:ger...@autonomie.demon.co.uk>
Okay, here it is. Keep your Holiday list centrally or somewhere like the
DB's Profile document.
REM"26Sep97 R.Gill. Working Day Algorithm. Ok up to 1000 working days.";
REM;
REM"This list of holidays comes from somewhere in the system";
Holidays:="01/01/97":"01/10/97":"01/15/97":"01/04/2000";
REM"Incoming: PeriodStart as text, Duration as numeric. Return:
WorkDays as text list";
REM"Define a plausible calendar end date as text";
PeriodEnd:=@Text(@Adjust(@TextToTime(PeriodStart);0;0;@Max(@Integer(Duration*1.5);30);0;0;0));
REM"Make a list of dates in text format";
DateList:=@Explode(@TextToTime(PeriodStart+"-"+PeriodEnd));
REM"Make a corresponding list of the day of the week for each entry,
also in text format";
DayNumbers:=@Text(@Weekday(@TextToTime(DateList)));
REM"Mark weekend days with a NULL";
MarkWeekends:=@Replace(DayNumbers;"1":"7";"");
REM"Make a single list consisting of weekday (# or NULL) concatenated to
date";
DayDate:=MarkWeekends+DateList;
REM"Remove items from the original list that match the new list (i.e.
they don\'t begin with #) and zap NULL\'s";
Weekdays:=@Trim(@Replace(DateList;DayDate;""));
REM"Next, remove dates in the Holidays list";
NoHolidays:=@Trim(@Replace(Weekdays;Holidays;""));
REM"Finally, cut the list to the desired number of work days.";
WorkDays:=@Subset(NoHolidays;Duration);
@If(@Elements(Workdays)=Duration;WorkDays;"error in workday
calculation")