count the number of days exactly currentdate to only one month back not more then one month back
1. number of rows all
2. count the number of days exactly currentdate to开发者_运维技巧 only one month back not more then one month back
select count(id) from table where campaign_edate(exactly 1monthback) < CURDATE( )`
how to write query for this?
ex
id campaign_edate
1 29-03-2011
2 28-02-2011
3 1-03-2011
4 10-03-2011
result returns number of days 2
3. count number of rows where expirydate>currentdate
I want query for the above three count(number of rows)... query want to return 3count as result
The question is hazy however taking what you have entered, I'm guessing you are looking for something like:
Select Count(*)
From Table
Where Date_Add( campaign_edate, INTERVAL -1 MONTH ) < CURDATE()
Still, that doesn't make as much sense as finding intervals that end in a month:
Select Count(*)
From Table
Where campaign_edate < Date_Add( CURDATE(), INTERVAL 1 MONTH )
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-sub
use the date and time functions
edit:
noticed that there is a lot more to this question after I fixed the code formatting =)
counting
Date and Time functions
Not exactly sure what you want to count.
SELECT count(*) FROM table WHERE expirydate > CURDATE();
精彩评论