可以用CTime的成员函数Format生成m_strFilter

解决方案 »

  1.   

    谢谢了!
    还想请教:如何与数据库中的datetime类型的数据(日期一列)进行比较?
      

  2.   

    CString strTime = time.Format();
    CString str = time.Format("%Y-%M-%D %h:%m:%s");
    还可以在Format(str)指定日期地格式。详情参见MSDN。
      

  3.   

    CTime   Time;
    CString m_strFilter=time.Format();
    不过呢,你最好看看msdn!!
      

  4.   

    CTime::Format 
    CString Format( LPCTSTR pFormat ) const;CString Format( UINT nFormatID ) const;Return ValueA CString that contains the formatted time.ParameterspFormatA formatting string similar to the printf formatting string. Formatting codes, preceded by a percent (%) sign, are replaced by the corresponding CTime component. Other characters in the formatting string are copied unchanged to the returned string. See the run-time functionstrftime for details. The value and meaning of the formatting codes for Format are listed below: %D   Total days in this CTime
    %H   Hours in the current day
    %M   Minutes in the current hour
    %S   Seconds in the current minute
    %%   Percent sign 
    nFormatIDThe ID of the string that identifies this format. ResCall this member function to create a formatted representation of the date/time value. If the status of this CTime object is null, the return value is an empty string. If the status of CTime is invalid, the return value is an empty string.Example// example for CTime::Format and CTime::FormatGmt
    CTime t( 1999, 3, 19, 22, 15, 0 ); 
    // 10:15PM March 19, 1999
    CString s = t.Format( "%A, %B %d, %Y" );
    ASSERT( s == "Friday, March 19, 1999" );
      

  5.   

    我用CTime定义了时间控件对应的变量
    CTime date;
    CRecord * m_set;(CRecord 中有对应数据库表中列的变量m_date,表中列定义为Datetime类型;//赋值
    m_set->m_date=date;
    UpdateData(TRUE);结果数据库表中得到的列date的值不仅有年、月、日,还有时、分、秒,如何只取其中的年、月、日,赋值给数据库中的date列呢?