Nothing like a little brain teaser first thing in the morning! I am sure
this could be improved but with a little imagination here is something that
should work.....
function GetSundayCnt(D: TDateTime): integer;
var
Yr,Mo,Da: word;
BeginMonth: TDateTime;
EndMonth: TDateTime;
Sun: TDateTime;
DOW: integer;
S: integer;
begin
DecodeDate(D,Yr,Mo,Da);
BeginMonth := EncodeDate(Yr,Mo,1);
DecodeDate(IncMonth(BeginMonth,1),Yr,Mo,Da);
EndMonth := EncodeDate(Yr,Mo,Da) - 1;
DOW := DayOfWeek(BeginMonth);
S := (8 - DOW) MOD 7;
Sun := BeginMonth + S;
result := 0;
While Sun <= EndMonth do
begin
result := result + 1;
Sun := Sun + 7;
end;
end;
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Agustin Galloso Viera
Sent: Wednesday, May 18, 2005 9:53 AM
To: Borland's Delphi Discussion List
Subject: Calculating Sundays ...
Hi Delphicians ...
How I know how many Sundays have some month in some year ?? for example : if
i have May 2005 it give me 5. There are any function that resolve this, any
WEb about this, article, etc ??
Thanks 4 all...
---
Agustin Galloso Viera
[EMAIL PROTECTED]
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi