marijn marijn - 7 months ago 9
SQL Question

date(now) only working with time 00:00:00

I'm trying to get the number of rows where the date is today. Its working like this but only if the time is

00:00:00
so if i change the time to for example
2016-04-25 05:30:30
its not counting that row for some reason.

$result16 = $dbhandle->query("SELECT * FROM email WHERE signoff = DATE(NOW() )");
$row_cnt16 = $result16->num_rows;


What should I do to fix this?

Table information:
signoff = varchar(250)


Outputs:
if date is
2016-04-25 00:00:0
0 the output is 2
and if the date is
2016-04-25 05:04:00
output is
1

Answer

try this:

SELECT *
FROM email 
WHERE signoff BETWEEN DATE(NOW()) AND  DATE(NOW() + INTERVAL 1 DAY)
Comments