1。我建了一个acess数据库,其中有一个字段用来保存日期,我把数据类型设为“日期/时间”,可是存储的是'2002-12-12 13:34:12‘我想只存储日期2002-12-12
怎么办?
2。
在执行SQL语句
Select * from 表1 where riqi between '2002-12-12'and '2002-12-12'
怎么不行呢
我如果想查一个时间段怎么做呢?
怎么办?
2。
在执行SQL语句
Select * from 表1 where riqi between '2002-12-12'and '2002-12-12'
怎么不行呢
我如果想查一个时间段怎么做呢?
第二:时间格式不对,Access跟SQL server不一样的
int age;
CString str;
char name[12];
strcpy(name,"02/27/1975");
age=88; str.Format("select * from users where birthday = #%s#",name); m_list.DeleteAllItems();
m_pRecordset->Open(_bstr_t(str),_variant_t((IDispatch*)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
AddToList();
m_pRecordset->Close();
你照我这样写吧,我试过的,我能用
比如: Cstring str = COleDateTime()::GetCurrectTime().Format("%Y-%m-%d");
不知你用的是什么
我的字段类型是CTIME
所以我的程序是这样写的
CTime time;
time=CTime::GetCurrenttime();
m_column1=time;
你那种方法虽然可行但好象查询的时候麻烦
以我这样的方法存储的该怎么查询?
{
// TODO: Add your command handler code here//特别的时间查询 #03/08/1975# also is ok CString birth;
birth.Format("#1975-01-01#"); CString str;
str.Format("select * from users where birthday=%s",birth); if(m_pSet->IsOpen())
{
m_pSet->Close();
}
m_pSet->Open(CRecordset::dynaset,str);
UpdateData(FALSE);}
下面一条语句什么地方错了?
strsql.Format("Select * from 表1 where riqo between #2002-12-24 14:35:45# and #2002-12-25 14:37:01# and number='LWJA9'");
#什么作用〉?