access 的时间查询问题
我定义的时间格式如:2004-7-12
查询语句为strQuery = "select * from Sales where SaleDate between '"+sStartD+"' and '"+sEndD+"'";
为ado+access
其中 变量类型为 _variant_t strQuery;
CString sStartD; // "2002-1-1"
CString sEndD; // "2004-2-2"
编译通过但运行时出错,何故?
问题点数:0、回复次数:2Top
1 楼laiyiling(陌生人[MVP])回复于 2004-08-03 19:27:42 得分 0
sql="select * from USER where time>#"+m_tBeginTime.Format("%Y-%m-%d %H:%M:%S")+"# and time<#" + m_tEndTime.Format("%Y-%m-%d %H:%M:%S")+"#";Top
2 楼hust_dufei(小川)回复于 2004-08-03 20:01:51 得分 0
补充一下
access中InDate字段的格式为“日期/时间”:2004-7-12
我想查询例如:2004-1-2 至 2001-1-1 之间的纪录
CString sStartD;CString sEndD;
sStartD.Formate("%d-%d-%d",i1,i2,i3); //i1=2004, i2=7,i3=12
sEndD.Formate("%d-%d-%d",j1,j2,j3); //j1=2001, j2=1,j3=1
我用laiyiling的方法 strQuery = "select * from Sales where SaleDate<#"+sStartD+"# and SaleDate>#"+sEndD+"#";
不行,???
Top




