我想查询一段时间的数据
代码:m_sqlStr.Format(_T("select * from table1 where 时间 between '2011-06-01' and '2011-08-01'"));
但是查询出来的时候记录集是空的。ACCESS 数据库中的时间类型改成文本,时间 都不可以。我在添加数据的时候是通过获取时间控件的时间值添加进去的。m_dateTime.GetTime(m_time);
m_strTime.Format(_T("%d-%d-%d" ),m_time.GetYear(),m_time.GetMonth(),m_time.GetDay());m_list.InsertItem(0,m_strTime);//插入行m_dataMember.m_pRecord->PutCollect("时间",_bstr_t(m_strTime)); 不知道是哪点出错了,望大家能帮我看一下
代码:m_sqlStr.Format(_T("select * from table1 where 时间 between '2011-06-01' and '2011-08-01'"));
但是查询出来的时候记录集是空的。ACCESS 数据库中的时间类型改成文本,时间 都不可以。我在添加数据的时候是通过获取时间控件的时间值添加进去的。m_dateTime.GetTime(m_time);
m_strTime.Format(_T("%d-%d-%d" ),m_time.GetYear(),m_time.GetMonth(),m_time.GetDay());m_list.InsertItem(0,m_strTime);//插入行m_dataMember.m_pRecord->PutCollect("时间",_bstr_t(m_strTime)); 不知道是哪点出错了,望大家能帮我看一下
access里具体怎么转换,你可以查查相关资料
select * from table1 where 时间 between #2011-06-01# and #2011-08-01#
select * from table1 where 时间 between #2011-06-01# and #2011-08-01#楼上的正解,谢谢。但是现在我要把具体的时间改成时间控件中的变量 该如何了?
timeStrBack.Format(_T("%d-%d-%d" ),m_Tback.GetYear(),m_Tback.GetMonth(),m_Tback.GetDay());
timeStrFront.Format(_T("%d-%d-%d" ),m_Tfront.GetYear(),m_Tfront.GetMonth(),m_Tfront.GetDay());
m_sqlStr.Format(_T("select * from table1 where 时间 between #%s# and #%s#"),timeStrFront,timeStrBack);