一个月的最后一天
function LastDayOfMonth(Dat: TDate): TDate;
var
D, M, Y : Word;
begin
DecodeDate(IncMonth(Dat, 1), Y, M, D);
Result := EncodeDate(Y, M, 1) - 1;
end;
function LastDayOfMonth(Dat: TDate): TDate;
var
D, M, Y : Word;
begin
DecodeDate(IncMonth(Dat, 1), Y, M, D);
Result := EncodeDate(Y, M, 1) - 1;
end;
(*
function StartOfTheMonth(const AValue: TDateTime): TDateTime;
function EndOfTheMonth(const AValue: TDateTime): TDateTime;
function StartOfAMonth(const AYear, AMonth: Word): TDateTime;
function EndOfAMonth(const AYear, AMonth: Word): TDateTime;
*)procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(DateToStr(StartOfTheMonth(Date)));
ShowMessage(DateToStr(EndOfTheMonth(Date)));
end;
procedure TForm1.Button1Click(Sender: TObject);
var
D, M, Y : Word;
begin DecodeDate(DateTimePicker1.Date, Y, M, D);
DateTimePicker1.Date := EncodeDate(Y, M, 1);
end;别忘了给分哦,哈哈
Var
Year, Month, Day : WORD;
FirstDay, EndDay : TDateTime;
Begin
DecodeDate( YourDate, Year, Month, Day );
FirstDay = EnCodeDate( Year, Month, 1 );
If Month = 12 Then EndDay = EncodeDate( Year, month, 31 )
Else EndDay = ( Year, Month + 1, 1 ) - 1;
End
//DaysInMonth()取回一个月总天数
//DayOf()取回当前天数//取回本月第一天
Date() - DayOf(date()) + 1 ;
//取出本月最后一天
Date() - DayOf(date()) + DaysInMonth(date());