I am trying to create startDate in yyyymmdd format so that this date is on the 1st of the third month. For example, the current month is July (07), so I need my start date to be April 1st (04) - 20150401.
To achieve this in bash, I used the following command:
StartDate=$(date -d "-3 month -$(($(date +%d)-1)) days" +"%Y%m%d")
However, this gives me the following error:
line 93: 09: value too great for base (error token is "09")
I do not want to change the format of the StartDate variable. For unambiguous months (1-9), the format should have a leading zero edge of the month number in yyyymmdd format.
Is there something I am missing?
Thanks in advance!
source
share