关于日期查询的问题?(在线等待)

zongbing 2003-12-27 11:43:04
如:"select * from dd where rq =#" & rqdata & "#"
rqdata="2003-12-12" 或者"03-12-12"
在WIN2000中可到结果,但在WIN98中一样的语句,在数据库里查询不到结果,请问怎么解决?请详细说明!
...全文
47 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
Wonny 2003-12-29
  • 打赏
  • 举报
回复
您可以在 SQL 子句中使用 Datepart(year,datefield)=年,Datepart(month,datefield)=月,Datepart(day,datefield)=日
taojy 2003-12-29
  • 打赏
  • 举报
回复
使用日期时间的时候我从不用日期时间型,我用字符型,感觉好用得多
iiboy 2003-12-29
  • 打赏
  • 举报
回复
在ACCESS中使用where data_field=cdate("datastring")
sysroger 2003-12-29
  • 打赏
  • 举报
回复
先format日期格式。
kbkingbird 2003-12-29
  • 打赏
  • 举报
回复
如果是我做,我就用format转换格式~~~不知道这样做是否正确~~
软侠 2003-12-29
  • 打赏
  • 举报
回复
用格式化函数可以让你只输入月份和日期(或年月日),然后自动转换成你所要的日期格式.
软侠 2003-12-29
  • 打赏
  • 举报
回复
为什么不用格式化函数先将rqdata格式化成系统可以识别的日期格式?这只是我的想法,不一定正确
busisoft 2003-12-27
  • 打赏
  • 举报
回复
sql win2000中
select * from dd where rq ='" & format(rqdata,"yyyy-MM-dd") & "'"
hlm750908 2003-12-27
  • 打赏
  • 举报
回复
我原来也遇见过日期查询的问题
你试试
不用条件
查询
输出日期字段值(可用断点调试,跟踪变量值)

看格式,究竟是哪几个字符,什排列格式
yyyy-mm-dd
yy-mm-dd
mm-dd-yyyy
mm-dd-yy

对我原来 就是这样解决的
hlq8210 2003-12-27
  • 打赏
  • 举报
回复
小马哥说的不错
yoki 2003-12-27
  • 打赏
  • 举报
回复
Win2000与Win98的日期格式是不一样的,你可以将Win98的日期格式设为与Win200一致。方法:控制面板——》区域设置--》日期

当然你也可以直接这样:
select * from dd where rq =#" & format(rqdata,"yyyy-MM-dd") & "#"

(如果是sqlserver数据库,那么须将#换成')
rianer 2003-12-27
  • 打赏
  • 举报
回复
If Option3.Value Then
If Text4.Text = "" Or Text5.Text = "" Or Len(Text4.Text) < 4 Then
MsgBox "请您完整填写查询时间!", vbOKOnly + vbInformation, "查询"
Exit Sub
End If
wherestr = wherestr + "出生日期 < '" & Text4.Text & "-" & Text5.Text & "-" & 1 & "'"
End If
If Option4.Value Then
If Text4.Text = "" Or Text5.Text = "" Or Len(Text4.Text) < 4 Then
MsgBox "请您完整填写查询时间!", vbOKOnly + vbInformation, "查询"
Exit Sub
Else
wherestr = wherestr + "出生日期 >'" & Trim$(Text4.Text) & "-" & Trim$(Text5.Text) & "-" & 31 & "'"
End If
End If

If Option5.Value Then
If Text4.Text = " " Or Text5.Text = " " Or Text8.Text = "" Or Text9.Text = "" Or Len(Text4.Text) < 4 Or Len(Text8.Text) < 4 Then
MsgBox "请您完整填写查询时间!", vbOKOnly + vbInformation, "查询"
Exit Sub
Else
wherestr = wherestr + "出生日期 Between '" & Text4.Text & "-" & Text5.Text & "-" & 1 & "' And '" & Text8.Text & "-" & Text9.Text & "-" & 1 & "'"
End If
End If

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧