Subtract month and day mysql
I need to subtract 1 month and 4 days with mysql, I saw the command
DATE_ADD (NOW (), - 1 MONTH)
perfect for 1 month but for 1 month and 4 days, using 31 days is not valid for every month that some bring 30, 29, 28. I can not add 31 + 4, 30 + 4, etc.
Solution 1:
using DATE_SUB
[docs]
like :
DATE_SUB((DATE_SUB(curdate(), INTERVAL 1 MONTH)), INTERVAL 4 DAY)
Solution 2:
SELECT DATE_ADD(DATE_ADD(NOW(),INTERVAL -1 MONTH), INTERVAL -4 DAY)