I'm trying to use the ADDDATE function on a value in the table.
UPDATE 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)
Use the DATE_ADD() function if you want to increase a given date in a MySQL database. In our example, we increased each start date by two days. This function takes two arguments.
How do I find last 30 days in SQL? SELECT * FROM product WHERE pdate >= DATEADD(day, -30, getdate()).
DATE_ADD() function in MySQL is used to add a specified time or date interval to a specified date and then return the date. Specified date to be modified. Here the value is the date or time interval to add. This value can be both positive and negative.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With