|
阅读:1188回复:1
[求助]时间查询问题
<P>想要读取属性表中的时间字段,来查询某月的相关记录,请问如何构造SQL语句,我的写的代码如下,请大家指点迷津</P>
<P> tDateTime1 = FormatDateTime(CStr(StartDTPicker.Month) ; "-" ; CStr(1) ; "-" ; CStr(StartDTPicker.Year), vbGeneralDate)<BR> tDateTime2 = FormatDateTime(CStr(StartDTPicker.Month + 1) ; "-" ; CStr(1) ; "-" ; CStr(StartDTPicker.Year), vbGeneralDate)<BR> tDateTime1 = CStr("CONVERT(" ; "datetime," ; CStr(tDateTime1) ; ")")<BR> tDateTime2 = CStr("CONVERT(" ; "datetime," ; CStr(tDateTime2) ; ")")<BR> sSQL = "FASJ>=" 'FASJ是属性表中的时间字段<BR> sSQL = sSQL + tDateTime1<BR> sSQL = sSQL ; " " ; "AND" ; " " ; "FASJ<"<BR> sSQL = sSQL + tDateTime2<BR> Query sSQL ' 自定义的函数</P> |
|
|
1楼#
发布于:2007-07-04 23:58
<P>你把条件表达式提取出来先在sql中使用看看可以通过吗</P>
|
|
|