This should do it, don't know if you are using D7 so have included some
functions from its date utilities.

function StartOfTheMonth(const AValue: TDateTime): TDateTime;
var
  LYear, LMonth, LDay: Word;
begin
  DecodeDate(AValue, LYear, LMonth, LDay);
  Result := EncodeDate(LYear, LMonth, 1);
end;

function DaysInMonth(const AValue: TDateTime): Word;
var
  LYear, LMonth, LDay: Word;
begin
  DecodeDate(AValue, LYear, LMonth, LDay);
  Result := DaysInAMonth(LYear, LMonth);
end;

 function IsDateSunday (const DT: TDateTime): Boolean;
begin
        Result := DayOfWeek (DT) = 1;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  MonthDays: word;
  FDate, FStart: TDateTime;
  i: integer;
begin
  FDate := StrToDate(Edit1.Text);
  MonthDays := DaysInMonth(FDate);
  FStart := StartOfTheMonth(FDate);
  for i := 0 to MonthDays - 1 do
  begin
     if IsDateSunday(FStart +i) then
      ListBox1.Items.Add(FormatDateTime(ShortDateFormat, FStart +i));
  end;
end;

Mike



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Agustin Galloso Viera
Sent: Thursday, 19 May 2005 12: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

Reply via email to