I’ve tried my best to try to find a solution, in threads and on documentation, but I can’t get it…
I just want to subtract 2 dates in format MM/DD/YY… and get the days between the 2 dates
Things that I tried…
{% set vacuum_last_used = as_timestamp(states('sensor.rockrobo_vacuum_v1_last_clean_end')) | timestamp_custom('%D') %}
{% set fecha_hoy = as_timestamp(states('sensor.date')) | timestamp_custom('%D') %}
# vacuum_last_used= 05/03/22
# fecha_hoy= 05/05/22
{{ (as_timestamp(states('sensor.date'), "%D")) - (as_timestamp(vacuum_last_used, "%D")) | int}}
{{ relative_time((strptime(fecha_hoy, '%D'))) - relative_time((strptime(vacuum_last_used, '%D'))) }}
(a){{ ((as_datetime(states('sensor.date')) - as_datetime(states('sensor.rockrobo_vacuum_v1_last_clean_end'))) | int /60/1440) | round(0) }}
{{ (strptime(fecha_hoy, '%D')) - (strptime(vacuum_last_used, '%D')) }}
I tried using as_timestamp and as_datetime… but bothing, I get errors that I can use the operato - with str, other error was TypeError: can't subtract offset-naive and offset-aware datetimes
in condition (a)
If you could help me…
Thank you!
1 post - 1 participant