Einzelnen Beitrag anzeigen

Yheeky

Registriert seit: 7. Jun 2002
1.339 Beiträge
 
#2
  Alt 10. Feb 2003, 21:53
Das sollte funktionieren:

Code:
function TForm1.NumOfWeek(ADate: TDateTime): Integer;
var
 d,m,y,h : Word;
 Jan: TDateTime;
 Days : Integer;
begin
 try
   DecodeDate(ADate, y, m, d);
   Jan:= EncodeDate(y, 1, 1);
   h:= DayOfWeek(Jan);
   Days:= Trunc(Int(aDate) - Jan) + 7 - DayOfWeek(ADate - 1);
   Inc(Days, 7 * Ord(h in [2..5]));
   Result := Days div 7;
   if Result = 0 then
     if (DayOfWeek(EncodeDate(Pred(y), 1, 1)) >5)
      or (DayOfWeek(EncodeDate(Pred(y), 12, 31)) <5) then
        Result:= 52
     else
       Result:= 53
   else
     if Result = 53 then
       if (h >5) or (DayOfWeek(EncodeDate(y, 12, 31)) <5) then
         Result:= 1;
 except
   Result := 0;
 end;
end;
Gruß Yheeky
  Mit Zitat antworten Zitat