select date_format(pubdate,'%Y-%m-%d %H:%i:%s') as date from table
唉,其实DATE_FORMAT('2002-08-26','%Y-%m-%d %T')就可以了.
select count(*) from luntan where id!=0 and date_format(date,'%Y-%m-%d')>=2002-08-26 and date_format(date,'%Y-%m-%d')<=2002-08-27 order by date desc 这样写正确吗?我在mysql中运行,count(*)为0,而实际上我的数据库中有两条记录,为什么?请大侠指教!!!
select count(*) from luntan where id!=0 and date_format(date,'%Y-%m-%d')>='2002-08-26' and date_format(date,'%Y-%m-%d')<='2002-08-27' order by date desc
用以下这一句更好 select count(*) from luntan where id!=0 and ( date_format(date,'%Y-%m-%d') between '2002-08-26' and '2002-08-27') order by date desc
DATE_FORMAT('2002-08-26','%Y-%m-%d %H:%T:%S')
select count(*) from luntan where id!=0 and ( date_format(date,'%Y-%m-%d') between '2002-08-26' and '2002-08-27') order by date desc