关于时间的查询
#define DEF_OPEN_TIME "09:00:00"
this->ADOQuery1->Close();
this->ADOQuery1->SQL->Clear();
strSQL = "SELECT time,value FROM shane ";
strSQL += "WHERE '";
strSQL += pForm3->DateTimePicker2->Time.TimeString();
strSQL += "' >= cdate(time) AND cdate(time) >= 'DEF_OPEN_TIME'";
this->ADOQuery1->SQL->Text = strSQL;
this->ADOQuery1->Open();
这段代码为什么查询不出数据?
[解决办法]
你用的2009或2010或XE吧.
改成:
AnsiString strSQL = AnsiString().sprintf(
"SELECT MD005,MD007,MD016 FROM shane "
"where cdate(MD007) <= '%s' and cdate(MD007) >= '%s'",
AnsiString(FormatDateTime("hh:nn:ss", pForm3->DateTimePicker2->Time)),
DEF_OPEN_TIME);