# Index rollover with date and time

**URL:** <https://discuss.elastic.co/t/index-rollover-with-date-and-time/283458>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [September 6, 2021, 2:56pm UTC](https://discuss.elastic.co/t/index-rollover-with-date-and-time/283458 "2021-09-06T14:56:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Felipe\_Fuller](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felipe_fuller/32/80377_2.png) [@Felipe\_Fuller](https://discuss.elastic.co/u/Felipe_Fuller)\
**Post date:** [September 6, 2021, 2:56pm UTC](https://discuss.elastic.co/t/index-rollover-with-date-and-time/283458/1 "2021-09-06T14:56:34Z")

</div>

Hi Community!

I'm trying to create an index rollover with the date and hour when the new index is created because I set up the rollover every hour during the day. Having this in consideration, the format of the new index should be:

```auto
my-index-2021.09.06.14-000001

```

Is there a way to do this? I tried using date math and returns just the date:

```auto
PUT %3Cmy-index-%7Bnow%2Fd%7D-000001%3E

```

Also tried this, and it doesn't gives the actual time.

```auto
PUT /%3Cmy-index-%7Bnow%2Fd%7BYYYY.MM.dd.HH.mm%7D%7D%3E

```

Thank you very much!

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 6, 2021, 3:10pm UTC](https://discuss.elastic.co/t/index-rollover-with-date-and-time/283458/2 "2021-09-06T15:10:03Z")

</div>

Hey,

I just tried

```bash
curl -X PUT 'localhost:9200/<logstash-%7Bnow%7Byyyy.MM.dd-HH.mm%7D%7D>'

```

which does not do any `now/d` tricks, because that will always mean the start of the day, if you use hours and minutes.

Does that help?

---

<div class="post-metadata">

**Author:** ![Felipe\_Fuller](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felipe_fuller/32/80377_2.png) [@Felipe\_Fuller](https://discuss.elastic.co/u/Felipe_Fuller)\
**Post date:** [September 6, 2021, 3:14pm UTC](https://discuss.elastic.co/t/index-rollover-with-date-and-time/283458/3 "2021-09-06T15:14:39Z")

</div>

so you can't timestamp the time of the new index rollover?

For example,

```auto
my-index-2021.09.06.14.14.00-000001
my-index-2021.09.06.14.15.00-000001
my-index-2021.09.06.14.16.00-000001
etc...

```

thanks!

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 6, 2021, 3:19pm UTC](https://discuss.elastic.co/t/index-rollover-with-date-and-time/283458/4 "2021-09-06T15:19:00Z")

</div>

Have you tried the above example? If not, do 🙂

That said, I hope you do not aim for indices by the minute and this is just to keep the creation date in the index name 🙂

---

<div class="post-metadata">

**Author:** ![Felipe\_Fuller](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felipe_fuller/32/80377_2.png) [@Felipe\_Fuller](https://discuss.elastic.co/u/Felipe_Fuller)\
**Post date:** [September 6, 2021, 3:33pm UTC](https://discuss.elastic.co/t/index-rollover-with-date-and-time/283458/6 "2021-09-06T15:33:40Z")

</div>

Thank you very much! It worked! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 4, 2021, 3:34pm UTC](https://discuss.elastic.co/t/index-rollover-with-date-and-time/283458/7 "2021-10-04T15:34:32Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
