开发者

count data in current month in MySQL

dear all. i have a lot of data in my database. after that i have some MySQL code for counting data. i want to make them can count monthly.

how to make this code can count just in current month? its mean if now september, it was just co开发者_高级运维unting on this month. and the data from the other month is ignored. whats MySQL code to make it so that it can complete the code in the page link?


If you use the MySQL function NOW, you won't have to calculate the date in PHP:

WHERE YEAR(payment_date) = YEAR(NOW()) AND MONTH(payment_date) = MONTH(NOW())


where date < '09-30-2010' and date >= '09-01-2010'


WHERE MONTH(Inspection_datetime) = MONTH(CURRENT_DATE) 
AND YEAR(Inspection_datetime) = YEAR(CURRENT_DATE)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜