aspose file tools*
The moose likes JDBC and the fly likes modifying date in mysql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "modifying date in mysql" Watch "modifying date in mysql" New topic
Author

modifying date in mysql

Anand Bhatt
Ranch Hand

Joined: May 30, 2007
Posts: 189
Hi,
I have a row which contains date format,I would add the 7days to the current day of that day
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
use the date_add built in function and use an interval of 7 day.



http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-add
[ December 10, 2008: Message edited by: Paul Campbell ]
Anand Bhatt
Ranch Hand

Joined: May 30, 2007
Posts: 189
I have tried this function,but unfortunately getting this error:
ADDDATE('2004-1-10', INTERVAL 7 DAY)


You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ADDDATE('2004-1-10', INTERVAL 7 DAY)' at line 1.

I would like to mention that I am using MySQl5.0
Anand Bhatt
Ranch Hand

Joined: May 30, 2007
Posts: 189
pAUL ONE MOR THING ,WHEN i FOLLOW THIS LINK
AND TRIED SOMETHING LIKE :


GOT THE RESULT LIKE THIS:

'2008-12-11'+INTERVAL 7 DAY
---------------------------
0x323030382d31322d3138


I AM WONDERING WHY I AM NOT GETTING THE DESIRED RESULT.PLEASE CORRECT ME.
Anand Bhatt
Ranch Hand

Joined: May 30, 2007
Posts: 189
Thanks, now I get the desired result.
Thanks a lot Paul.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38334
    
  23
Please take caps lock off when posting ordinary text.
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
Originally posted by Anand Bhatt:
I have tried this function,but unfortunately getting this error:
ADDDATE('2004-1-10', INTERVAL 7 DAY)



I would like to mention that I am using MySQl5.0


Try this... I believe it is because you used '1' instead of '01' for your month... but to be sure you should probably make sure that the database engine knows your date and its format by using to_date in the function.

ADDDATE(TO_DATE('2004-01-10','YYYY-MM-DD'), INTERVAL 7 DAY)
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
Originally posted by Anand Bhatt:
Thanks, now I get the desired result.
Thanks a lot Paul.


Good... I was going off of memory... I don't use MySQL that much here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: modifying date in mysql