ACCESS库中日期时间过滤
各位大虾好:
我在PB8中联接了ACCESS库,表名叫aaa,其中有个是日期/时间字段是A
其中有一些时间数据如:2006-03-13 08:01:01,2006-03-13 12:01:01,2006-03-13 15:01:01
我想查询2006-03-13 12:01:01的数据.代码
string f
f="a>=datetime('2006-03-13 09:01:01') and a<=(2006-03-13 14:01:01)"
dw_1.setfilter(f)
dw_1.filter()
可是我过滤出来确是2006-03-13的所有数据, 请各位大虾指点
问题点数:20、回复次数:4Top
1 楼jiangsheng(蒋晟.Net[MVP])回复于 2006-03-18 11:40:07 得分 0
比较的时候用#2006-03-13 14:01:01#,不要用字符串比较
建议使用Access的参数化查询,直接传递日期类型的参数。Top
2 楼PENGPENG2006()回复于 2006-03-18 11:49:54 得分 0
什么是Access的参数化查询Top
3 楼jiangsheng(蒋晟.Net[MVP])回复于 2006-03-18 14:40:31 得分 0
打开Access数据库,选择查询,在设计视图中选择查看->参数……Top
4 楼debye(德拜)回复于 2006-03-18 15:11:09 得分 0
pb的datetime()函数的参数是不支持直接用字符串的,必须这样写
datetime(date('2006-03-13'),time('09:01:01'))
我想可能是这个原因。
DateTime ( date {, time } )
Argument Description
date A valid date (such as Jan 1, 1998, or 12-31-99) or a blob variable whose first value is a date that you want included in the value returned by DateTime.
time
(optional) A valid time (such as 8am or 10:25:23:456799) or a blob variable whose first value is a time that you want included in the value returned by DateTime. If you include a time, only the hour portion is required. If you omit the minutes, seconds, or microseconds, they are assumed to be zeros. If you omit am or pm, the hour is determined according to the 24-hour clock.
Top




