获得的pubtime为String型,在sql语句中用mysql的时间函数date_format('time','format')转换:
String sqlstr="select * from do_document where
pub_time<date_format('"+pubtime+"','%Y-%m-%d %H:%i:%s') order by pub_time desc limit 0,1";
然后执行该sql语句就查到了满足条件的记录。
用法:
select count(*) from MESSAGE where date_format(sendTime,'%Y-%m-%d') = '2010-11-16'