i have postedon field as timestamp
i was doing
select * from table where postedon=curdate();
to find total post ,posted today
but it returns no thing though there are rows which match that condition...
any idea of doing it
how to find topic posted today in php /mysql
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
using a timestamp is kind of limiting, if you were using a datetime field it would be much easier to do this SQL side. In your case of using a timestamp, to be accurate you want to grab the first second of today and simply check if any dates are greater than that.
You can use this function getFirstSecond(); in combination with
You may be able to play with UNIX_TIMESTAMP and INTERVAL to get it all SQL if you wish, I just can't right now (too early) 
You can use this function getFirstSecond(); in combination with
Code: Select all
mysql_query('SELECT * FROM `table` WHERE `timestamp` > \''. getFirstSecond(); .'\' ORDER BY `timestamp`DESC') or die(mysql_error());