[ACCEPTED]-Mysql query: retrieve current date query-database
Accepted answer
You don't need to use PHP, MySQL has a function 6 to get the current date:
SELECT field FROM table WHERE DATE(column) = CURDATE()
If 5 your column is only ever going to need the 4 date part and never the time, you should 3 change your column type to DATE. If you 2 insist on doing it through PHP, it is the 1 same thing, really:
$today = date('Y-m-d');
$query = mysql_query("
SELECT field FROM table WHERE DATE(column) = '$today'
");
For date time it is not usefull, instead 2 I try this and working...
Today's Visitors!
sql 1 > select user_id from users where last_visit like concat('%' , CURDATE() , '%');
// last_visit coloumn of type 'datetime'
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.