Bash – Add 30 days in date

bashdateMySQL

Using bash or mysql , how can I add 30 days in user expiry table?

Example I have DB name USERS and table expiry like this:

USERNAME   EXPIRATION
JOHN       2015-09-26

I want the command to take whatever value is in EXPIRATION column for a specified USERNAME and add 30 days to it

So the result would be:

USERNAME   EXPIRATION
JOHN       2015-10-26

Best Answer

Using GNU date :

$ date -d '2015-09-26 +30 days' '+%Y-%m-%d'
2015-10-26
Related Question