Cannot set date in input_datetime before 2001?

In an attempt to calculate days alive in a template sensor, I’ve tried to put birthdays in an input_datetime first

alias: New Script
  - service: input_datetime.set_datetime
      date: '2001-01-01'
        - input_datetime.birthdate_sam

The above works, but anything in or before that year doesn’t work. Is this a known limitation, or am I really missing out on something here?

Are there errors in your log when you attempt to set that?

None, whatsoever. The date just doesn’t change.

I just tried with one and could set it to before 2001 just fine.

Same here.

I’ve been quite stupid for about an hour, I see.


what was it?

1 Like

I was mixing up the changing of the input_datetime.set_datetime (which works), with the template sensor not calculating.

      value_template: "{{((as_timestamp(now()) - as_timestamp(states('input_datetime.birthdate_sam'))) / 86400) | int }}"
      friendly_name: Sam days Alive

ah, well

      value_template: {{ (now() - states('input_datetime.birthdate_sam') | as_datetime | as_local).days }}
1 Like