有没有办法显示所选日期的日期?

问题描述 投票:0回答:1

我想显示所选月份当前日期旁边的日期,同时循环显示该月的所有日期。

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)
,但它不起作用,它总是返回“星期六”,十月的第一天,十月的所有日子。

loops date datetime delphi winapi
1个回答
0
投票

使用

DayofWeek(dtCurrentDate)
而不是
DayofWeek(CalendarView1.Date)

© www.soinside.com 2019 - 2024. All rights reserved.