mysql 日期比较

select * from tb where c> date_format('2007-07-06','%Y%m%d') and c <= date_format('2007-07-09','%Y%m%d');


select * from tb where c> date('2007-07-07') and c< date('2007-07-09')


STATDAY是形如2006031001的日期数据字段
select * from LOGINSTAT where STATDAY> date_format(curdate()-1,'%Y%m%d') and STATDAY >= date_format(curdate(),'%Y%m%d');
或者:
select * from LOGINSTAT where STATDAY> date_format(curdate()-1,'%Y%m%d %H') and STATDAY >= date_format(curdate(),'%Y%m%d %H');
其他用法:
select * from LOGINSTAT where STATDAY >= date_format('$date1','%Y%m%d%H') and STATDAY < date_format('$date','%Y%m%d%H')

猜你喜欢

转载自qiuqiutang.iteye.com/blog/1390281