Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calculating # Business Days

7 views
Skip to first unread message

Lee Tankersley

unread,
Apr 27, 1998, 3:00:00 AM4/27/98
to

Thoughts on how to calc the number of Business(not calendar) days between
two dates?

James Joyce

unread,
Apr 29, 1998, 3:00:00 AM4/29/98
to

No specific code for you, but some (@function) thoughts.

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/

Manon

unread,
Apr 29, 1998, 3:00:00 AM4/29/98
to

I never use it, I take it from this group, some time ego.
the question was : Re: Num of Days calculation - weekends

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>...

abdul

unread,
Apr 29, 1998, 3:00:00 AM4/29/98
to

This is an old formula for calculating no. of weekdays b/w two dates....


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.

Gerry King

unread,
May 2, 1998, 3:00:00 AM5/2/98
to

In article <6i3go7$4...@bgtnsc03.worldnet.att.net>, Lee Tankersley
<ltank...@worldnet.att.net> writes

>Thoughts on how to calc the number of Business(not calendar) days
>between
>two dates?
Download Raymond LaTulippe's 'Formulas & Scripts' library from
Frank Cseh's superb Notes site http://www.best.com/~cseh

The first 'compound formula' does this - there are hundereds of other
useful examples.

Gerry King
<URL:mailto:ger...@autonomie.demon.co.uk>

Dick Gill

unread,
May 3, 1998, 3:00:00 AM5/3/98
to Lee Tankersley

Lee Tankersley wrote:
>
> Thoughts on how to calc the number of Business(not calendar) days between
> two dates?

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")

0 new messages