格式為2008-06-16
查詢出當(dāng)天數(shù)據(jù):
SELECT * FROM `table` WHERE date(時(shí)間字段) = curdate();
查詢出當(dāng)月字段:
SELECT *
FROM `table`
WHERE month( 時(shí)間字段) = month( now( ) ) ;
時(shí)間格式為1219876…… UNIX時(shí)間,只要應(yīng)用“FROM_UNIXTIME( )”函數(shù)
例如查詢當(dāng)月:
SELECT *
FROM `table`
WHERE month( from_unixtime( reg_time ) ) = month( now( ) ) ;
查詢上一個(gè)月的呢?變通一下!
SELECT *
FROM `table`
WHERE month( from_unixtime( reg_time ) ) = month( now( ) ) -1;
如對本文有疑問,請?zhí)峤坏浇涣髡搲?,廣大熱心網(wǎng)友會為你解答??! 點(diǎn)擊進(jìn)入論壇