注册 登录
编程论坛 Delphi论坛

如何实现日期的比较?

qpfmates 发布于 2008-10-19 13:22, 1689 次点击
我在做图书管理系统,判断是否超期,要比较时间,如何实现?望高手指点
1 回复
#2
ruanjian21102008-10-21 10:31
放两个DateTimePicker控件进行比较就行了,我以前做过类似的,给点代码你参考下。。
if CheckBoxtime.Checked=true   then
   begin
     if DateTimePicker1.DateTime>DateTimePicker2.DateTime then
       begin showmessage('查询时间有误,请正确选择查询时间!');exit;end;
   end;
 if CheckBoxtime.Checked=true   then
   begin
     if DateTimePicker1.DateTime<DateTimePicker2.DateTime then
      begin
      wherestr:=wherestr+' ( ReTime>='''+datetimetostr(DateTimePicker1.DateTime)+''' and ReTime<='''+datetimetostr(DateTimePicker2.DateTime)+''')';
      wherestr1:='and';
      end;
   end;
1