高手,帮帮忙,日期比较问题,在线等候 我建了两个DTPicker用来输入日期,date1,date2,我查询sql server数据库中的记录,data表中有一个定义为datetime型的字段saledate,查询条件是where (data.saledate>" + date1.value + "and data.saledate<" + date2.value + ") 运行时,总显示类型不匹配,为什么,先谢了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我也是但要把date 改为String就行了。唉。。 Access:where (data.saledate>#" + date1.value + "# and data.saledate<#" + date2.value + "#)SQL Server:where (data.saledate>'" + date1.value + "' and data.saledate<'" + date2.value + "') 当然了,你要换成字符型才可以HSQL = " saledate BETWEEN '" + CStr(Format(Sdate.Value, "YYYY-MM-DD")) + "' AND '" + CStr(Format(Edate.Value, "YYYY-MM-DD")) + "'"HSQL = "select * from " & HTable & " where " + HSQL + " order by sa_code" 不提示错误了,但是查不出记录啊,为什么啊,表里面是datetime型的啊,为什么要转换为字符型啊,谢谢了 你可以跟踪 date1.value 的形式是不是‘yyyy-mm-dd’,如果是就可以不转化,其实你所说的转化也只是规定它的格式而已 Access下建议试试where (data.saledate>#" & format( date1.value,"yyyy-mm-dd") & "# and data.saledate<#" & format (date2.value ,"yyyy-mm-dd") & "#) 查询条件改为"... where data.saledate between #" + date1.value + "# and #" + date2.value + "#"不行发消息给我 where (data.saledate>" + date1.value + "and data.saledate<" + date2.value + ")where (data.saledate>'" + date1.value + "' and data.saledate<'" + date2.value + "')"1、你的括号有问题,是中文的2、日期需要用''3、有时候datetime需要这种形式才能查询到数据where (data.saledate>'" + date1.value + " 00:00:00' and data.saledate<'" + date2.value + " 23:59:59')" VB6.0编译时出现 对象'Refresh'的方法'IAdodc' 公司领导很黄很暴力 紧急求救:谁使用过cell报表控件? 请教两个遇到的小问题哦,不知道是不是有解哦? Run Timer Error 424 Object Required. activex控件注册问题 怎样屏蔽treeview中的鼠标高亮度显示功能? VB中的实时帮助怎么实现? 关于odbc的2个问题 如何打印rtf格式的文本? vb小程序备份数据资料怎么实现?我用access作存储文件?说详细点吧,谢谢 26号放假回家了,家里是小猫会很少来这里了,感谢大家以前的帮助,散分!!!
但要把date 改为String就行了。
唉。。
where (data.saledate>#" + date1.value + "# and data.saledate<#" + date2.value + "#)SQL Server:
where (data.saledate>'" + date1.value + "' and data.saledate<'" + date2.value + "')
where (data.saledate>#" & format( date1.value,"yyyy-mm-dd") & "# and data.saledate<#" & format (date2.value ,"yyyy-mm-dd") & "#)
"... where data.saledate between #" + date1.value + "# and #" + date2.value + "#"
不行发消息给我
2、日期需要用''
3、有时候datetime需要这种形式才能查询到数据
where (data.saledate>'" + date1.value + " 00:00:00' and data.saledate<'" + date2.value + " 23:59:59')"