I have the following SQL query in PHP:
SELECT *, DATE_FORMAT(datetime_accessed , '%y,%m,%d')
FROM e_track_access_log
WHERE datetime_accessed = CURDATE() - INTERVAL 0 DAY AND member_id >'0'
ORDER BY datetime_accessed DESC LIMIT 0,5
What I am trying to do is draw information from the SQL database to only show information from the current day. The problem now is I am not getting any data from the SQL displayed.
My Column is a DateTime format I cannot change that as this is how the raw data is pushed from my service provider. I know I did exactly the same with just a Date Column and it worked great. Is there away I am not telling it to look up the current Column format?
Or am I missing something totally different here?
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$result = mysql_query("SELECT *, FROM e_track_access_log
WHERE datetime_accessed = CURDATE() - INTERVAL 0 DAY AND member_id >'0'
ORDER BY datetime_accessed DESC LIMIT 0,5");
?>
<br>
<?php
while($rows=mysql_fetch_array($result)){
This is the whole code I am using then the Echo's but they too long to post here
Use the following condition to get all records for the current day:
WHERE DATE(datetime_accessed) = CURDATE()
The condition you have only matches rows where the time is 00:00:00
.
Try this...
SELECT *, DATE_FORMAT(datetime_accessed , '%y,%m,%d') FROM e_track_access_log WHERE DATE(datetime_accessed) = CURDATE() AND member_id >'0' ORDER BY datetime_accessed DESC LIMIT 0,5