filter里面不能使用Convert语句。如何解决?

zhouxiaochenchina 2004-12-23 10:49:14
我原来语句如下

stemp:='2004%';
filtered:=false;
//date1为datetime类型
filter:=' Convert(date1,varchar(20)) like '''+stemp+'''';
filtered:=true;

这样是不支持的,如何解决?
...全文
124 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
johnnyzhou_chn 2004-12-23
  • 打赏
  • 举报
回复
zhouxiaochenchina 2004-12-23
  • 打赏
  • 举报
回复
这个我也知道啊,那样打开一下,我要是数据量大,多慢
herman~~ 2004-12-23
  • 打赏
  • 举报
回复
同意楼上
imhere_l 2004-12-23
  • 打赏
  • 举报
回复
而且,如果数据量比较大,最好是用sql语句重新查询
imhere_l 2004-12-23
  • 打赏
  • 举报
回复
不是这个意思。比如:
select a, b, convert(date1,varchar(20)) as c from table
就可以直接使用字段c进行过滤了
JonnySun 2004-12-23
  • 打赏
  • 举报
回复
那樣當然不支持啦!請看說明:

Filters can compare field values to literals and to constants using the following comparison and logical operators:


Operator Meaning
< Less than
> Greater than
>= Greater than or equal to
<= Less than or equal to
= Equal to
<> Not equal to
AND Tests two statements are both True
NOT Tests that the following statement is not True
OR Tests that at least one of two statements is True
+ Adds numbers, concatenates strings, adds numbers to date/time values (only available for some drivers)
- Subtracts numbers, subtracts dates, or subtracts a number from a date (only available for some drivers)
* Multiplies two numbers (only available for some drivers)
/ Divides two numbers (only available for some drivers)
* wildcard for partial comparisons (FilterOptions must include foPartialCompare)



其它解決方案是在你想Filter它的時候, 用SQL語句重新查詢

Select * from mytable where ' Convert(date1,varchar(20)) like '''+stemp+''''


imhere_l 2004-12-23
  • 打赏
  • 举报
回复
看能否在提取数据的时候先行处理数据类型转换。而不是数据到前台后再进行。
zhouxiaochenchina 2004-12-23
  • 打赏
  • 举报
回复
什么意思?
imhere_l 2004-12-23
  • 打赏
  • 举报
回复
放到代码中去处理。

2,497

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧