求一个月的第一天和最后一天:
function THiSettlForm.Init:string;
begin
dtp1.DateTime:=FDOM(Now);
dtp2.DateTime:=LDOM(Now);
end;
function THiSettlForm.FDOM(Date: TDateTime): TDateTime;
var Year, Month, Day: Word;
begin
DecodeDate(Date, Year, Month, Day);
//month:=dec(month);
if Month >1 then
dec(Month)
else
begin
Month := 12;
dec(year) ;
end;
Result := EncodeDate(Year, Month, 1); end;
function THiSettlForm.LDOM(Date: TDateTime): TDateTime;
var Year, Month, Day: Word;
begin DecodeDate(Date, Year, Month, Day);
// if Month < 12 then inc(Month)
// else begin Month := 1;inc(Year) end;
Result := EncodeDate(Year, Month, 1) - 1;
end;
浙公网安备 33010602011771号