[wd_asp elements=’search’ ratio=’100%’ id=1]

Current date in mysql curdate()

8th October 2013

MySql

mysql codehaven category

This will produce 2013-10-29
SELECT NOW(); // You will get 2010-12-09 17:10:18
SELECT CURDATE(); // You will get 2010-12-09

Another example is $query = "INSERT INTO table1 (date, time, operator, status, completed, name, email) VALUES (CURDATE(), CURTIME(), '".$operator."', '".$status."', '".$complete."', '".$name."', '".$email."')";

Tomorrows dateSELECT CURDATE()+1;

And some more interesting ways…select curdate();
-- 2011-01-31

select cast(curdate() as datetime);
-- 2011-01-31 00:00:00

select if('2011-01-31' <= curdate(), 'yep', 'not this time'); -- yep select if('2011-01-31 00:00:01' <= curdate(), 'yep', 'not this time'); -- not this time select if('2011-01-31 01:00:00' <= adddate(curdate(), interval 1 day), 'yep', 'not this time'); -- yep

And another
$result = mysql_query("SELECT * FROM cmdata WHERE date=curdate() and time=DATE_FORMAT(NOW(),'%H')");

More info here about other formats like hour etc