急!! 100分!!Value assigned to 'Date2' never used; Value assigned to 'Date1' never used;
procedure TFormCommonQuery.Button1Click(Sender: TObject);
var
sqlstr:string;
Date1:TDate;
Date2:TDate;
Function FormatStringDate(s :string):String;
begin
FormatStringDate:=Copy(S,1,4)+'-'+Copy(S,5,2)+'-'+Copy(S,7,2);
end;
begin
ShortDateFormat:='yyyy-mm-dd';
DateSeparator:='-';
if Edit5.Text <> '' then
begin
try
strtoint(Edit5.Text);
Except
SHowmessage('输入的必须为8位数字');
edit5.SetFocus;
Edit5.SelectAll;
exit;
end;
if Length(edit5.Text) = 8 then
date1 := strtodate(FormatStringDate(Edit5.text))
else
begin
showmessage('输入的不是有效日期,正确形式如20080101');
edit5.SetFocus;
edit5.SelectAll;
exit;
end;
if Edit6.Text <> '' then
begin
try
strtoint(Edit6.Text);
Except
SHowmessage('输入的必须为8位数字');
edit6.SetFocus;
edit6.SelectAll;
exit;
end;
if Length(edit6.Text) = 8 then
date2 := strtodate(FormatStringDate(Edit5.text))
else
begin
showmessage('输入的不是有效日期,正确形式如20080101');
edit6.SetFocus;
edit6.SelectAll;
exit;
end;
with query1 do
begin
close;
SQL.Clear;
SQL.add('select PlanInfo.ID,PlanInfo.Name,Money,TimePlan,TimePlanStart,TimePlanEnd,PlanInfo.PersonDuty,Place,Introduce,TimeStart,Progress,TimeEnd from PlanInfo,ProInfo where PlanInfo.ID =ProInfo.ID AND');
SQl.add('convert(varchar(10),TimePlanStart,120) >:date1 AND convert(varchar(10),TimePlanEnd,120) <:date2');
Open;
end;
end