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
sequence:
  - service: input_datetime.set_datetime
    data:
      date: '2001-01-01'
    target:
      entity_id:
        - 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.

:fearful:

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.

    sam_days_alive:
      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