function DiasMes(fecha: TdateTime): integer;
var
mes,anno : integer;
begin
mes:=StrToInt(formatDateTime('mm',fecha));
anno:=StrToInt(formatDateTime('yyyy',fecha));
case mes of
2: if IsLeapYear(anno) then
Result:=29
else
Result:=28;
1,3,5,7,8,10,12: Result:=31;
4,6,9,11: Result:=30;
end;
end;
function SiEsDomigo(Fecha_:Variant): integer;
begin
if DayOfWeek(Fecha_)=1 then Result:=0
Else Result:=1;
End;
function DomingosMes(Fechita:Variant): integer;
Var
FechaCreada,xx:String;
I,NDomingos:Integer;
begin
xx:=DateToStr(Fechita);
NDomingos:=0;
For I:=1 to DiasMes(Fechita) Do
Begin
FechaCreada:=IntToStr(i)+'/'+copy(xx,4,7);
If SiEsDomigo(StrToDate(FechaCreada)) = 0 Then
NDomingos:=NDomingos+1;
End;
Result:=NDomingos;
End;
procedure TForm1.Button1Click(Sender: TObject);
Var
I,NDomingos:Integer;
FechaCreada,xx:String;
begin
Label1.Caption:=IntToStr(DiasMes(DateTimePicker1.Date));
Label2.Caption:=IntToStr(DomingosMes(DateTimePicker1.Date));
end;