DotDragnet
May 23, 2012, 09:23:17 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: follow us on twitter @dotdragnet
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: mysql date question  (Read 1079 times)
Charisma Bypass
Hero Member
*****
Posts: 556



View Profile Awards
« on: March 05, 2009, 11:40:44 AM »

I have to get a date, add 30 days to it and then insert that new date into a table...

Gettind the date is easy, it's the date of purchase: $order->info['date']

Adding 30 days, I thought to use the INTERVAL 30 DAY

So, my end code looks like;

("
insert into XYZ (code, amount, date) values ('123', '15', '" . $order->info['date'] . "'
");

The above works fine - it inserts the necessary details.  I can't get the right syntax to add the 30 days onto the date.  Date looks like this: 2009-02-12 22:05:01

Thank You in advance for any help.
Logged
sarahA
DDN Contribs
Hero Member
*****
Posts: 2176



View Profile WWW Awards
« Reply #1 on: March 05, 2009, 12:08:26 PM »

Code:
insert into XYZ (code, amount, date) values ('123', '15', DATE_ADD('" .$order->info['date'] . "', INTERVAL 30 DAY)

should work
Logged

Charisma Bypass
Hero Member
*****
Posts: 556



View Profile Awards
« Reply #2 on: March 05, 2009, 01:39:10 PM »

Thanks Sarah, appreciate that big grin

I ended up using;

'" . $order->info['date'] . "' + interval 30 day
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2006-2008, Simple Machines Valid XHTML 1.0! Valid CSS!