silenxe
路人甲
路人甲
  • 注册日期2006-09-24
  • 发帖数9
  • QQ
  • 铜币173枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1188回复:1

[求助]时间查询问题

楼主#
更多 发布于:2007-07-04 17:28
<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>
喜欢0 评分0
cl991036
管理员
管理员
  • 注册日期2003-07-25
  • 发帖数5917
  • QQ14265545
  • 铜币29669枚
  • 威望217点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • GIS帝国铁杆
1楼#
发布于:2007-07-04 23:58
<P>你把条件表达式提取出来先在sql中使用看看可以通过吗</P>
没钱又丑,农村户口。头可断,发型一定不能乱。 邮箱:gisempire@qq.com
举报 回复(0) 喜欢(0)     评分
游客

返回顶部