VB6.0数据库两时间段查询的疑惑
发布网友
发布时间:2024-10-11 02:57
我来回答
共2个回答
热心网友
时间:2024-11-23 21:34
NOW函数的付值里已经含了时间部份发,不能在查询的地方加入时间的,其实为了强制实现从当月1号查起,就不改加入DTPicker1控件,而应该这样做吧
sql = "select * from jibenxinxi where date BETWEEN #" & year(DTPicker2.Value ) & "-" & month(DTPicker2.Value ) & "-1 00:00:00# And #" & year(DTPicker2.Value ) & "-" & month(DTPicker2.Value ) & "-" day(DTPicker2.Value) & " 23:59:59#"
热心网友
时间:2024-11-23 21:35
date是保留字,用的时候要用中括号括起来,这样即可:
ql = "select * from jibenxinxi where [date] BETWEEN #" & format(DTPicker1.Value,"yyyy-MM-01") & "# And #" & DTPicker2.Value & " 23:59:59#"