小弟有这样一个问题!我现在想比较Edit.Text的时间字符和指定字符进行对比.但是不知道怎么写想法是这样的if (Edit1.Text > StrToTime('08:00:00')) and (Edit1.Text < StrToTime('20:00:00')) then
Edit1.Text的格式为 2007-05-27 10:28:00 现在我只想比对时间部分.不能小于 08:00:00 不能大于 20:00:00请求各位大虾的帮助,小弟在线等啊
Edit1.Text的格式为 2007-05-27 10:28:00 现在我只想比对时间部分.不能小于 08:00:00 不能大于 20:00:00请求各位大虾的帮助,小弟在线等啊
s,s1,s2:string;
begin
s :='2007-05-27 09:00:00';
s2:='2007-05-27 10:00:00';
s1:=RightStr( s,8 ); if ( s1 > '08:00:00' ) and ( s1 < '10:00:00' ) then
.........
else
.........//or s1:=ForMatDateTime( 'hh:mm:ss',StrToDateTime( s2 ) );
if ( s1 > '08:00:00' ) and ( s1 < '10:00:00' ) then
........
else
.........end;
var
H,M,S,Z : word;
H1,M1,S1,Z1,H2,M2,S2,Z2 : word;
begin
DecodeTime(StrToDatetime(Edit1.Text), H, M, S, Z);
DecodeTime(StrTotime('08:00:00'), H1, M1, S1, Z1);
DecodeTime(StrTotime('20:00:00'), H2, M2, S2, Z2);
if (((H*60+M)*60+Z) > ((H1*60+M1)*60+Z1)) and (((H*60+M)*60+Z) < ((H2*60+M2)*60+Z2))
then ShowMessage('Edit1的时间在8:00-20:00之间');
end;