Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

modifying date in mysql

 
Anand Bhatt
Ranch Hand
Posts: 189
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 338
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 189
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 189
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 189
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, now I get the desired result.
Thanks a lot Paul.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47285
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take caps lock off when posting ordinary text.
 
Paul Campbell
Ranch Hand
Posts: 338
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 338
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic