homepage Welcome to WebmasterWorld Guest from 54.167.185.110
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
now()
Lolalola




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

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


Thanks

 

coopster




msg:4124328
 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




msg:4124497
 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved