Bash "1 day ago" results in invalid date

Hi
I have a sh file I need to run. In this file I find the date for yesterday.

I find the date as follows:
$ (date “+% Y-% m-% d” -d “1 days ago”)

However, this gives me the error:
date: invalid date ‘1 days ago’

If I run the above in a terminal using Ubuntu it works fine, what am I doing wrong?

Why not just subtract a day from the function now() in home assistant?

I have many lines of code in my sh file. I need to find the date in my sh file. I have been using this sh file on another linux powered pc for the last 7 years without any issues. Now I would like to use it in HA.

I have found another solution:
$ (date -d @ $ (($ (date + “% s”) - 86400)) + “% Y-% m-% d”)

But I still do not understand why the first one does not work.

Considering this is a Home Assistant forum you might be better off asking somewhere like Stack Exchange.

The date command (and many others, I presume) in my HA ssh addon is actually Busybox, and not a GNU tool. It most likely doesn’t support the same range of options that you’d get from a standard Linux host.

Yes it must be a limitation in HA. Just a strange one.