请问各位前辈过滤条件怎么写?(100分)

  • 主题发起人 主题发起人 guixm001
  • 开始时间 开始时间
G

guixm001

Unregistered / Unconfirmed
GUEST, unregistred user!
d1:=encodedate(se_year.Value,se_month.Value,1);
d2:=encodedate(se_year.Value,se_month.Value+1,1);
Tab_yuanclrk.Filter:= 'fld_riq<=d2 and fld_riq>=d1';
上面的代码哪里有错,我不明白,se_year,se_year分别是用来输入年月的Tspinedit.
 
Tab_yuanclrk.Filter:= 'fld_riq<='''+d2 +''' and fld_riq>=''' +d1+'''';
 
Tab_yuanclrk.Filter:= 'fld_riq<='+''''+d2+'''' +'and fld_riq>='+''''+d1+'''';[:)]
 
在Filter事件中写吧
 
我认为应该这么写:
Tab_yuanclrk.Filter:=
'fld_riq<='''+datetostr(d2) +''' and fld_riq>=''' +datetostr(d1)+'''';

或者可以这么写
Tab_yuanclrk.Filter:=
'fld_riq between '''+datetostr(d2) +''' and ''' +datetostr(d1)+'''';

 
检查D1和D2的时间格式吧。
 
用SetRange 比较好吧,只在本地执行,效率也要高点。
 
Tab_yuanclrk.Filter= 'fld_riq<='+#39+d2+#39+'and fld_riq>='+#39+d1+#39
試試,我用過了,呵呵
 
各位前辈:
谢谢你们的回答,可是上面的几种方法小弟都试过,不行的,还有没有别的可行的方法。
 
d1:=encodedate(se_year.Value,se_month.Value,1);
d2:=encodedate(se_year.Value,se_month.Value+1,1);
Tab_yuanclrk.Filter:= 'fld_riq<=d2 and fld_riq>=d1';
==>
Tab_yuanclrk.Filter:=Format('fld_riq<=''%d/%d/%d'' and 'fld_riq>=''%d/%d/%d''',
[se_month, Value, se_year, se_month, value+1, se_year]);
注意日期格式:m/d/yyyy
 
记住,
d1 d2
是变量,而不是字串呀

你可以跟踪调试一下呀
 
1.Tab_yuanclrk.Filter:= 'fld_riq<='+d2 +' and fld_riq>=' +d1;
2.检查日期格式


 
各位前辈,我试了一下,都不行,但我现在有了答案,和大家分享吧
Tab_yuanclrk.Filter:= 'fld_riq<='''+formatdatetime('yyyy-mm-dd',d1) +''' and fld_riq>= '''+ formatdatetime('yyyy-mm-dd',d2)+'''';
顺便给各位一点辛劳分,不要嫌少。
 
后退
顶部