日期的比较,该如何解决
日期的比较
DataModule35->qry1->SQL->Add("Select * from Card where CompareDateTime(StrToDateTime(EndTime),FormatDateTime("yyyy-mm-dd",Now())) <= 0");
我用数据库里面记录的日期与当前的日期比较,为什么这样不行,会出现错误?
------最佳解决方案--------------------
sql语句和c++要分开的
------其他解决方案--------------------
sql中可以直接使用符合日期格式的字符串与日期类型比较
比如:
select *from table where startime>'2011-3-1'
------其他解决方案--------------------
直接在SQL里判断
sql = " Select * from Card where EndTime <= GetDate()"
qry1->SQL->Add(sql)
------其他解决方案--------------------
那应该如何连接呢?
------其他解决方案--------------------
------其他解决方案--------------------
大概是这个思路,代码你写
DataModule35->qry1->SQL->Add("Select * from Card where CompareDateTime(StrToDateTime(EndTime),FormatDateTime("yyyy-mm-dd",Now())) <= 0");
我用数据库里面记录的日期与当前的日期比较,为什么这样不行,会出现错误?
------最佳解决方案--------------------
sql语句和c++要分开的
------其他解决方案--------------------
sql中可以直接使用符合日期格式的字符串与日期类型比较
比如:
select *from table where startime>'2011-3-1'
------其他解决方案--------------------
直接在SQL里判断
sql = " Select * from Card where EndTime <= GetDate()"
qry1->SQL->Add(sql)
------其他解决方案--------------------
那应该如何连接呢?
------其他解决方案--------------------
DataModule35->qry1->SQL->Add("Select * from Card where EndTime<:dt");
DataModule35->qry1->Paramters->ParamsByName("dt")->Value := Date();
DataModule35->qry1->Open();
------其他解决方案--------------------
大概是这个思路,代码你写