Welcome to WebmasterWorld Guest from 23.22.46.195

Forum Moderators: open

now()

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

10+ Year Member



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)

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



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)

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



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.
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month