select hh_code_cu,hh_staff,sum(hh_out_big) as hh_count_big,sum(hh_out_small) as hh_count_small,cu_abbr_chi,em_name_chi from hh_whosale_trd,cu_customer,em_employee where hh_state=1 and cu_code=hh_code_cu and em_code=hh_staff and hh_date>"&DateFrom&" and hh_date<"&DateTo&" group by hh_code_cu,hh_staff,cu_abbr_chi,em_name_chi order by hh_code_cu
请问为什么上面的语句加上 and hh_date>"&DateFrom&" and hh_date<"&DateTo&"条件的话就不能在页面中显示合乎条件记录。
可以使用 between 的啊
hh_date between "&datefrom&" and "&dateto&"
hh_date between "&datefrom&" and "&dateto&"
去掉单引号
字段必须是时间型 的。可以找到的。between and 统计出来的数据和这个效果是一样的。
hh_date >=&dateform& and hh_date<="&dateto&"
它包括这两个时间,你是不是没有理解意思?
试试吧。between and 是肯定可以用的。
应该没问题的 可以用between
同意楼上的说法
access中应该是下面的写法:
hh_date between #"& datefrom &"# and #"& dateto &"#
还有在得到时间的时候,最好用FormatDateTime函数处理一下,以防发生意外:
---------------------------------------------------------------
FormatDateTime
返回表达式,此表达式已被格式化为日期或时间。
语法
FormatDateTime(Date[, NamedFormat])
FormatDateTime 函数的语法有以下参数:
参数 描述
Date 必选。要被格式化的日期表达式。
NamedFormat 可选。指示所使用的日期/时间格式的数值,如果省略,则使用 vbGeneralDate。
设置
NamedFormat 参数可以有以下值:
常数 值 描述
vbGeneralDate 0 显示日期和/或时间。如果有日期部分,则将该部分显示为短日期格式。如果有时间部分,则将该部分显示为长时间格式。如果都存在,则显示所有部分。
vbLongDate 1 使用计算机区域设置中指定的长日期格式显示日期。
vbShortDate 2 使用计算机区域设置中指定的短日期格式显示日期。
vbLongTime 3 使用计算机区域设置中指定的时间格式显示时间。
vbShortTime 4 使用 24 小时格式 (hh:mm) 显示时间。
说明
下面例子利用 FormatDateTime 函数把表达式格式化为长日期型并且把它赋给 MyDateTime:
Function GetCurrentDate
FormatDateTime 把日期型格式化为长日期型。
GetCurrentDate = FormatDateTime(Date, 1)
End Function
--------------------------------------------------------------------------------