开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜