Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

As to the function, it determines how many weeks (full 7 days) have passed. That part is easy, because 7 days = 5. The remainer needs to be figured out based on day of the week that that the StartDate falls. (determine if the day count wraps into a weekend).

Regards,

Russell

----

function DaysWorkedSince(StartDate:

var dwDay: Integer;

dwTotal: Integer;

dwWeeks: Integer;

dwDays: Integer;

begin

// Get the day of week for the starting day (0 = Sunday and 6 = Saturday)

dwDay:=DateTimeToTimeStamp

// Subtract today and start date

dwTotal:=Trunc(Now - StartDate);

// Update by 1 if today should be included

if IncludeToday then Inc(dwTotal);

// Calculate the number of total weeks and remainder days

dwWeeks:=dwTotal div 7;

dwDays:=dwTotal mod 7;

// Weeks = 5 working days

result:=dwWeeks * 5;

// Check remainder days

if (dwDays > 0) then

begin

// Now figure in the days based on the starting date

case dwDay of

0 : Dec(dwDays);

1 : if (dwDays > 5) then dwDays:=5;

2 : if (dwDays > 4) then dwDays:=4;

3 :

begin

if (dwDays = 6) then

dwDays:=4

else if (dwDays > 3) then

dwDays:=3;

end;

4 :

begin

if (dwDays > 3) then

Dec(dwDays, 2)

else if (dwDays = 3) then

dwDays:=2;

end;

5 :

begin

if (dwDays > 2) then

Dec(dwDays, 2)

else if (dwDays = 2) then

dwDays:=1;

end;

6 :

begin

if (dwDays > 2) then

Dec(dwDays, 2)

else

dwDays:=0;

end;

end;

// Update result

Inc(result, dwDays);

end;

end;

ShowMessage(IntToStr(DaysW