SELECT NOW() + DAY(2) AS date, user_name FROM user_time Why i get always "Null"?
Thanks
coopster
1:34 pm on Apr 29, 2010 (gmt 0)
The syntax for the DAY [dev.mysql.com] function is incorrect. That function requires a date expression. What are you trying to accomplish? Add two days to the current date?
rocknbil
5:15 pm on Apr 29, 2010 (gmt 0)
Sounds like it . . . additionally remember that now() is a date and time result, curdate() is a date only result.
select date_add(curdate(),interval 2 day) as date, user_name from user_time
--> YYYY-MM-DD | rocknbil
select date_add(now(),interval 2 day) as date, user_name from user_time
--> YYYY-MM-DD HH:MM:SS | rocknbil
You can also wrap the date math functions in a date_format() command to extract a particular formatting output.