Invalid date

Hi, I have a function to calculate "yesterday" in format YYYYMMDD :

desa_ev9 # date +"%Y%m%d" --date "-1 day 20180701"
20180630

desa_ev9 # date +"%Y%m%d" --date "-1 day 20180720"
20180719

desa_ev9 # date +"%Y%m%d" --date "-1 day 20190101"
20181231

desa_ev9 # date +"%Y%m%d" --date "-1 day 20180913"
20180912

Works correctly but....

desa_ev9 # date +"%Y%m%d" --date "-1 day 20180812"
date: invalid date `-1 day 20180812'

What is the problem?

Welcome to the forum.

Works for me:

date +"%Y%m%d" --date "-1 day 20180812"
20180811

Anything special that you did between the before last and last command?

Now I see, you want 1 day less than a given date.
It should work. I successfully checked with several versions of GNU date.
If even

date +"%Y%m%d" --date "20180812 - 1 day"

does not work, then I suspect a bug in your date program.