Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding x number of days onto a mysql date

Status
Not open for further replies.

SPYDERIX

Technical User
Jan 11, 2002
1,899
CA
Hi there,

I have some fields in mysql (set as date) and I want to know if there is a php function or mysql function I could use to add on x number of days onto what I have stored. I know I could retrieve the date do a substr of it and then an mktime and then re-assemlbe and re-store but that's quite long winded. Was wondering if there is a faster/easier way to do this.

If the date is 2005-05-31 and I add 2 days onto that I need it to properly output as 2005-06-02.

Thanks for any help. I really appreciate it.

NATE


mainframe.gif


Got a question? Search G O O G L E first.
 
Hey TomThumbKP,

I found the answer. I can use SQL to do this.

UPDATE `table` SET `date` = DATE_ADD(`date`, INTERVAL X DAY) WHERE `id` = 1

Thanks for your time though.

NATE


mainframe.gif


Got a question? Search G O O G L E first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top