# How can I use %{+yyyy.mm.dd} in input?

**URL:** <https://discuss.elastic.co/t/how-can-i-use-yyyy-mm-dd-in-input/231535>\
**Category:** Logstash\
**Created:** [May 7, 2020, 12:16pm UTC](https://discuss.elastic.co/t/how-can-i-use-yyyy-mm-dd-in-input/231535 "2020-05-07T12:16:27Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [May 7, 2020, 3:55pm UTC](https://discuss.elastic.co/t/how-can-i-use-yyyy-mm-dd-in-input/231535/2 "2020-05-07T15:55:20Z")

</div>

> [@jinjinbari](#):
>
> input { elasticsearch{ hosts =\> ["localhost"] index =\> "test-%{+yyyy-MM-dd}" codec =\> "json" } }

A sprintf reference to a date, such as %{+yyyy-MM-dd} uses the value of @timestamp on an event to fill in the date. When the elasticsearch input is initializing there is no event, so there is no @timestamp field, so this does not work.

You might be able to use an environment variable. See [here](https://discuss.elastic.co/t/date-pattern-in-file-input-path/100538/3) for an example.

---

_[View the full topic](https://discuss.elastic.co/t/how-can-i-use-yyyy-mm-dd-in-input/231535)._
