Reputation: 53
I have a date for example: 20160808 which is stored in a variable $d_date. I have another variable that contains the number of days I need to add to the d_date. Which is $days. Lets say $days=378. I want to add 378 days to $d_date in my script. But it seems to ignore the $days when I use the following command.
end=`date -d "$d_date +$days days" +%Y%m%d`
When I debug the script it shows the following (related to this command):
++ date -d '20160808 + days' +%Y%m%d
+ end=572160721
Upvotes: 3
Views: 689
Reputation: 6061
This works:
d_date=20160808
days=378
end=`date -d "$d_date +$days days" +%Y%m%d`
echo $end
It gives next output:
20170821
Upvotes: 1