0

I need to find 1 month ago from a particular date. But for months with 31 days, I'm getting in-correct date as the output

For example, in the scenario below I should have got 20191130, but I got 20191201 as the output

curr_date=20191231
prev_month_date=$(date -d "$curr_date - 1 month" +%Y%m%d)
echo $prev_month_date
20191201
  • 2
    This was answered in the Unix StackExchange [here](https://unix.stackexchange.com/questions/207617/how-does-the-1-month-ago-option-in-date-command-work) – Alon Jan 01 '20 at 11:00
  • Thanks, but the shared discussion didn't provide the exact solution for my problem. – Vignesh Venugopal Jan 02 '20 at 02:59

0 Answers0