问题: 如何做一个提醒功能,根据系统时间和表内时间的差值进行提醒

解决方案1:

select MAX(日期)  as "max_rq" from table 
取字段值时:
fieldbyname("max_rq")即可取出最大日期

解决方案2:

1.Select '表名' AS A,Max(时间) AS B From 表名
2.Selct A,B From (
Select '表名1' AS A,Max(时间) AS B From 表名1
Union All
Select '表名'2 AS A,Max(时间) AS B From 表名2
Union All
.......这部分你可以在DELPHI中写好
Union All
Select '表名n' AS A,Max(时间) AS B From 表名n ) C
WHERE B=(Selete Max(B)  From C)
疑问:理论上同一表中,时间的最大值是唯一的,但对于多表,时间就有可能相等,也就是结果集中的记录数量存在大于一的可能性。

引用 楼主 u010003305 的回复:
现在已经完成了用系统时间去减表内的时间,但是现在有2个问题,我有好几个表,表内有好几个时间。如何判断一个表内的最大时间,也就是离系统最近的时间。还有如何逐个查询表,读取表内最大时间与系统时间相减,然后将表名字输出到memo?

解决方案3:

var NowDate,Date1,Date2,Date3,Date:TdateTime;
    MyList:TListString;
    S:string;
begin
  MyList:=TListString.Creat;;
  NowDate:=Now;
  Date1:=ClientDateSet1.FieldByName('时间').AsDateTime;
  Date2:=ClientDateSet2.FieldByName('时间').AsDateTime;
  Date3:=ClientDateSet3.FieldByName('时间').AsDateTime;
//......
  if (NowDate-Date1)1<>
    then Date:=Date1
    esle Date:=Date2;
  if Date>(NowDate-Date3) then Date:=Date3;
  S:=DateTimetoString(ID,'yyyy-mm-dd hh:nn:ss',Date);
  MyList.add('最近时间:'+S);
// ......
  Memo1.Item.text:=MyList.Text;
  Mylist.Free;
end;     
大致如此。

上一篇windows 2008 r2 socket建立连接慢的问题
下一篇delphi access数据库更新内容的问题?
明星图片
相关文章
《 如何做一个提醒功能,根据系统时间和表内时间的差值进行提醒》由码蚁之家搜集整理于网络,
联系邮箱:mxgf168#qq.com(#改为@)