我想显示所选月份当前日期旁边的日期,同时循环显示该月的所有日期。
var
dtSelectedDate, dtStartDate, dtEndDate, dtCurrentDate, d1: TDateTime;
begin
dtSelectedDate := DateOf(CalendarView1.Date);
dtStartDate := StartOfTheMonth(dtSelectedDate);
dtEndDate := EndOfTheMonth(dtSelectedDate);
EditMonth.Text := IntToStr(DaysInMonth(dtSelectedDate));
EditStartDay.Text := DateToStr(dtStartDate);
EditEndDay.Text := DateToStr(dtEndDate);
dtCurrentDate := dtStartDate;
while dtCurrentDate <= dtEndDate do
begin
T1.insert;
T1.FieldByName('Days').AsDateTime := dtCurrentDate;
T1.Post;
dtCurrentDate := dtCurrentDate + 1;
end;
end;
我尝试了
DayofWeek(CalendarView1.Date)
,但它不起作用,它总是返回“星期六”,十月的第一天,十月的所有日子。
使用
DayofWeek(dtCurrentDate)
而不是 DayofWeek(CalendarView1.Date)
。