毕设问题,在线等待大侠解答,多谢了先!!!(55分)

  • 主题发起人 主题发起人 attar
  • 开始时间 开始时间
A

attar

Unregistered / Unconfirmed
GUEST, unregistred user!
现在急需解决以下问题,望大侠们指点一二,我在线等待!
问题一:
我有Oracle字段 LogonTime是Date,LogoffTime是Date,SumTime是Number(3)
其中SumTime是LogonTime和LogoffTime相减的结果,比如
2002-5-30 12:12:12 2002-5-30 12:13:13 我想要的结果是1因为1分钟不足我约定的
15分钟,所以舍去,请问怎么实现日期减法?
再有就是我怎么得到SumTime的字段值,并显示到Edit.Text中去?
我试过
adoquery.sql.add('select sumtime from table1 where ……');
edit.text:=fieldbyname('sumtime').astring;
不成!!!怎么办?
问题二:
我怎么才能知道我Select * from table1;返回的结果是空的,就是说没有记录,
怎么知道?

在线等待!!!先谢谢看过此贴的朋友!!!


 
日期字段直接减,SQL语句中也可以
 
edit.text:=fieldbyname('sumtime').astring;
edit.text:=FormatDateTime('yyyy-mm-dd',fieldbyname('sumtime').asDateTime);
 
if Query.IsEmpty then
空的
else
不空
 
来自:yzhshi, 时间:2002-5-30 18:05:00, ID:1133616
edit.text:=fieldbyname('sumtime').astring;
edit.text:=FormatDateTime('yyyy-mm-dd',fieldbyname('sumtime').asDateTime);
好像不成!!!
 
function FormatDateTime(const Format: string; DateTime: TDateTime): string;
可以的,就是缺了adoquery
edit.text:=FormatDateTime('yyyy-mm-dd',adoquery.fieldbyname('sumtime').asDateTime);

 
问题一:
(1)关于日期相减:
有个不算太好但可行的方法:
先用to_char(列),再用substr(转换后的列字符)取出在分钟位置的字符有,
再用to_number()转换后相减,就得到整数结果了!
(2)adoquery.sql.add('select to_char(sumtime) as mycol from table1 where ……');
edit.text:=fieldbyname('mycol').astring;


问题二:
判断dataset的isempty即可,也可用recordcount
 
能写详细点么?
 
还是先多看点书,写起来会更须手的,磨刀不负砍柴功嘛。
 
With ADOQuery_Charge_SumTime Do
Begin
Close;
Sql.Clear;
Sql.Add('select SumTime from information where location='''+Edit_Location.Text+''' and Fee is null');
Open;
Edit_LogonTime.Text:=datetimetostr(FieldByName('SumTime').asdatetime);
end;

就是报错,Invalid Variant type conversion.
咋办?
 
你的SumTime明明是Number的怎么能用AsDateTime呢,用AsInteger然后再转换为TDateTime。
 
多人接受答案了。
 
后退
顶部