Rodo_Rodo
08-05-2007, 23:48:26
//*Esta Parte me Permite Hallar Los Dias de Un Determinado Mes
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;
//** La Funcion Me Indica si una Fecha En Particular Es Domingo
function SiEsDomigo(Fecha_:Variant): integer;
begin
if DayOfWeek(Fecha_)=1 then Result:=0
Else Result:=1;
End;
//* Ahh Y Esta me arroja la Cantidad De Domingos
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;
//*Prueba el Codigo en este boton Te Sorprenderas :)
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;
//Gracias a Todos Por las observaciones byyy
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;
//** La Funcion Me Indica si una Fecha En Particular Es Domingo
function SiEsDomigo(Fecha_:Variant): integer;
begin
if DayOfWeek(Fecha_)=1 then Result:=0
Else Result:=1;
End;
//* Ahh Y Esta me arroja la Cantidad De Domingos
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;
//*Prueba el Codigo en este boton Te Sorprenderas :)
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;
//Gracias a Todos Por las observaciones byyy