Welcome to WebmasterWorld Guest from 54.167.83.224

Forum Moderators: open

Message Too Old, No Replies

now()

     

Lolalola

9:23 am on Apr 29, 2010 (gmt 0)

Inactive Member
Account Expired

 
 


SELECT NOW() + DAY(2) AS date, user_name FROM user_time
Why i get always "Null"?


Thanks
1:34 pm on Apr 29, 2010 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12533
votes: 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?
5:15 pm on Apr 29, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 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.