我在VB里面用过的,就是用的字符串,当然在VB里面还要加#号的。
like : #2001-08-12#

解决方案 »

  1.   

    select * from table
    where datetime=#2002-12-12#
      

  2.   

    微软的数据库系统VFP,Access,SQL Server都可表示为#YYYY-MM-DD#
      

  3.   

    老兄的意思就是在VC中也可这样写?#YYYY-MM-DD#??
      

  4.   

    当然。#YYYY-MM-DD#这种表示在放在sql中的。
    比如DAO操作mdb.CDaoDatabase db;
    db.Open("xx.mdb");
    db.Execute("insert into tablename (start_time) values (#2002-02-04#)");
    db.Close();
      

  5.   

    CString sql;
    CString starttime,endtime,strTemp;



    strTemp.Format("%s%d","",m_dateFrom.GetMonth());
    starttime=strTemp+"/";
    strTemp.Format("%s%d","",m_dateFrom.GetDay());
    starttime=starttime+strTemp+"/";
        strTemp.Format("%s%d","", m_dateFrom.GetYear() );
    starttime=starttime+strTemp;
         strTemp.Format("%s%d","",m_dateTo.GetMonth());
    endtime=strTemp+"/";
    strTemp.Format("%s%d","",m_dateTo.GetDay());
    endtime=endtime+strTemp+"/";
    strTemp.Format("%s%d","", m_dateTo.GetYear() );
    endtime=endtime+strTemp;  sql="select distinct PaperCode from tblhardware where datediff('d','"+starttime+"',drawdate)>=0 and datediff('d',drawdate,'"+endtime+"')>=0";
        
    以上代码在中英文下均好用
      

  6.   

    以上的m_dateFrom,m_dateTo军为COleDateTime型变量