MySQL: Add 30 days to a value in the table
I'm trying to use the ADDDATE function on a value in the table.
UPD开发者_Python百科ATE credit SET addOns=ADDDATE(addOns, INTERVAL 30)
addOns is where I store the datetime. Why can I not add 30 days?
I also tried
UPDATE credit SET addOns=ADDDATE(SELECT addOns FROM credit, INTERVAL 30)
UPDATE credit SET addOns=ADDDATE(addOns, INTERVAL 30 DAY)
-- Or
UPDATE credit SET addOns=ADDDATE(addOns, 30)
If you specify INTERVAL, you must specify the unit; if you don't specify INTERVAL it will default to days.
UPDATE credit SET addOns=ADDDATE(addOns, INTERVAL 30 DAY)
Without interval keyword.
UPDATE credit SET addOns=ADDDATE(addOns, 30)
date_add(yourDate, INTERVAL 30 DAY)
精彩评论