现在在做一个查询,想把2个VC的日期控件显示的日期分别做为查询的条件,该做怎么处理呢

解决方案 »

  1.   

    首先读取日期控件日期,得到日期后,就可以用sql语句
    select * from table where time > #20090421# and time < #20090422#
      

  2.   

    我自己做的能用的,不过我用了四个日期控件,两选年月日,两个选时间。然后进行查询。
    int t_Num=0;
    CTime timestartT,timeendT,timestartD,timeendD;
    m_MyDateTimeCtrlStartDay.GetTime(timestartD);
    m_MyDateTimeCtrlEndDay.GetTime(timeendD);
    m_MyDateTimeCtrlStartTime.GetTime(timestartT);
    m_MyTimeDateCtrlEndTime.GetTime(timeendT);
    COleDateTime   timestartStrT;     
    timestartStrT.SetDateTime(timestartD.GetYear(),timestartD.GetMonth(),timestartD.GetDay(),timestartT.GetHour(),timestartT.GetMinute(),timestartT.GetSecond());  COleDateTime   timeendStrT ;     
    timeendStrT .SetDateTime( timeendD.GetYear(),timeendD.GetMonth(),timeendD.GetDay(),timeendT.GetHour(),timeendT.GetMinute(),timeendT.GetSecond());   CString sqlstr="select * from T_Sys_Operstion where Time_Operstion >='"+timestartStrT.Format("%Y-%m-%d %H:%M:%S")+"' and Time_Operstion<='"+timeendStrT.Format("%Y-%m-%d %H:%M:%S")+"'";给分!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      

  3.   

    CString sqlstr;
    strSql.Format("select * from a where time >'%s %s' and time<'%s %s'",
    startDay.Fromat("%Y-%m-%d"),startTime.Format("%H:%M"),
    endDay.Fromat("%Y-%m-%d"),endTime.Format("%H:%M"));
      

  4.   

    CString sqlstr; 
    strSql.Format("select * from a where time >'%s %s' and time <'%s %s'", 
    startDay.Fromat("%Y-%m-%d"),startTime.Format("%H:%M"), 
    endDay.Fromat("%Y-%m-%d"),endTime.Format("%H:%M"));