ClientDataSet的日期过滤失效问题?急(100分)

M

manboo

Unregistered / Unconfirmed
GUEST, unregistred user!
!ClientDataSet的日期过滤失效,如aDate>2002-11-2 无效根本没有效果啊!
快解决!死人啦!
 
看一下你windows的区域设置里的日期设置,最好是能设成长日期格式,我昨天才遇到
了这个问题,改为长日期之后,SQL的where用日期条件就正常了!
 
无效!我不是使用SQL,如果使用SQL的话,可以解决的,但是只是ClientDataSet的Filter
属性进行过滤的不是查询谢谢!
 
aDAte是日期型字段吧,应改为这样:
aDate>strtodatetime('2002-11-2');
 
能把你的代码贴出来看一下么?
还有,如果filter属性无效的话,你试一下clientdataset的onfilterrecord事件试试能不
能解决。
 
楼上的兄弟无效啦!现在绝望中!
 
改为:aDate>'2002-11-2 ' 就好了
 
不是的!我现在开始怀疑Borland的日期比较算法,靠!
 
我发现对于日期变量,比如:#02-7-27#和#2002-7-27#是不同的,我是郁闷到了极点了!
后来,我将短日期全部改为了长日期格式,问题消失。
 
请各位高手来看看这样一个问题
var
st,en:TDateTime;//分别定义起止日期
st:=strtodate(combobox1.Text+'-'+combobox2.Text+'-'+combobox4.Text);
en:=strtodate(combobox5.Text+'-'+combobox6.Text+'-'+combobox7.Text);
//转换从combobox输入的日期
with query1 do
begin
active:=false;
close;
sql.Clear;
sql.Add('select * from tela where name='''+edit1.Text+''' and stdate between:st and :en order by stdate,startt asc');
//stdate为数据库里日期的字段名,为datetime。名字符合条件,并且在界定的起止时间内的记录,并按时间排序。
open;
active:=true;
end;

这个代码编译通过,但在运行时会有这样的错误:
query1:Field 'st' is of an unknown type.
 
顶部