MY query looks like this:
SELECT COUNT(entryID)
FROM table
WHERE date >= DATE_SUB(CURDATE(), INTERVAL 1 DAY)
Will this count the rows whose date
values are within the day (starting at 12:00; not within 24 hours)? If not, how do I do so?
The following should be enough to get records within the current day:
SELECT COUNT(entryID)
FROM table
WHERE date >= CURDATE()
As Michael notes in the comments, it looks at all records within the last two days in its current form.
The >=
operator is only necessary if date
is actually a datetime
- if it's just a date
type, =
should suffice.
Here's the solution:
SELECT COUNT(entryID)
FROM table
WHERE DATE(date) >= CURDATE()
Since my date
column is type DATETIME
, I use DATE(date)
to just get the date part, not the time part.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With