Days between 2 dates

I’m trying to work out how to calculate the number of days between two dates, something like:

value_template: "{{ (as_timestamp(states.calendar.kayak_trips.attributes.end_time) - as_timestamp(now())) }}"

Just not sure how to format the result of this as a number of days?

subtracting 2 timestamps gives you the number of seconds that have elapsed between the two timestamps. To convert that to days, divide it by 86400

2 Likes