菜
菜鸟黄
Unregistered / Unconfirmed
GUEST, unregistred user!
问个超简单的问题~日期的计算问题~
下面的代码是要实现计算当前日期加x个星期后的日期是多少.不过做得不完善,超过两个月就实现不了这个功能了,请高手们给你指点,最好有代码给我看看.
var
Form1: TForm1;
O,P:integer;
Y,M,D,D1,A,B:integer;
procedure TForm1.Button1Click(Sender: TObject);
begin
O:=strtoint(edit3.Text);
P:=strtoint(edit4.Text);
Y:=YearOf(Date);
M:=MonthOf(Date);
D:=DayOf(Date);
D1:=DaysInAMonth(Y,M);
if (D+(7*P))<=D1 then
DateTimePicker1.Date := strtodate(inttostr(Y)+'-'+inttostr(M)+'-'+inttostr(D+(7*P)));
if (D+(7*P))>D1 then
DateTimePicker1.Date := strtodate(inttostr(Y)+'-'+inttostr(M+1)+'-'+inttostr(D+(7*P)-D1));
end;
下面的代码是要实现计算当前日期加x个星期后的日期是多少.不过做得不完善,超过两个月就实现不了这个功能了,请高手们给你指点,最好有代码给我看看.
var
Form1: TForm1;
O,P:integer;
Y,M,D,D1,A,B:integer;
procedure TForm1.Button1Click(Sender: TObject);
begin
O:=strtoint(edit3.Text);
P:=strtoint(edit4.Text);
Y:=YearOf(Date);
M:=MonthOf(Date);
D:=DayOf(Date);
D1:=DaysInAMonth(Y,M);
if (D+(7*P))<=D1 then
DateTimePicker1.Date := strtodate(inttostr(Y)+'-'+inttostr(M)+'-'+inttostr(D+(7*P)));
if (D+(7*P))>D1 then
DateTimePicker1.Date := strtodate(inttostr(Y)+'-'+inttostr(M+1)+'-'+inttostr(D+(7*P)-D1));
end;