# Index Date Math with seconds

**URL:** <https://discuss.elastic.co/t/index-date-math-with-seconds/276161>\
**Category:** Elasticsearch\
**Created:** [June 16, 2021, 3:50pm UTC](https://discuss.elastic.co/t/index-date-math-with-seconds/276161 "2021-06-16T15:50:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dimitris\_sb](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@dimitris\_sb](https://discuss.elastic.co/u/dimitris_sb)\
**Post date:** [June 16, 2021, 3:50pm UTC](https://discuss.elastic.co/t/index-date-math-with-seconds/276161/1 "2021-06-16T15:50:00Z")

</div>

Hi All,

When I try to create an index using date math expression

```auto
PUT /%3Cdata-index-%7Bnow%2Fm%7Byyyy-MM-dd-HH-mm-ss%7D%7D%3E

```

which produces an index as data-index-2021-06-16-12-41-00

Why seconds are always 00 (if you execute the same command multiple times)?

I think that seconds were supported:

> **[Date math support in index and index alias names | Elasticsearch Guide \[7.13\]...](https://www.elastic.co/guide/en/elasticsearch/reference/current/date-math-index-names.html)**

[https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html)

How can I add seconds to the expression?

Thank you in advance

---

<div class="post-metadata">

**Author:** ![angelo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/angelo/32/61325_2.png) [@angelo](https://discuss.elastic.co/u/angelo)\
**Post date:** [June 17, 2021, 3:24am UTC](https://discuss.elastic.co/t/index-date-math-with-seconds/276161/2 "2021-06-17T03:24:35Z")

</div>

You are only asking it to resolve to the minute, ie: `...{now/m{yyyy...` - to resolve down to the seconds, you need to change your expression to to be `...{now/s{yyyy...`:

```auto
PUT /%3Cdata-index-%7Bnow%2Fs%7Byyyy-MM-dd-HH-mm-ss%7D%7D%3E

```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 17, 2021, 3:41am UTC](https://discuss.elastic.co/t/index-date-math-with-seconds/276161/3 "2021-06-17T03:41:13Z")

</div>

Why are you using seconds in an index name?

---

<div class="post-metadata">

**Author:** ![dimitris\_sb](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@dimitris\_sb](https://discuss.elastic.co/u/dimitris_sb)\
**Post date:** [June 17, 2021, 12:42pm UTC](https://discuss.elastic.co/t/index-date-math-with-seconds/276161/4 "2021-06-17T12:42:01Z")

</div>

Thank you! I did not notice the precision parameter!

---

<div class="post-metadata">

**Author:** ![dimitris\_sb](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@dimitris\_sb](https://discuss.elastic.co/u/dimitris_sb)\
**Post date:** [June 17, 2021, 12:48pm UTC](https://discuss.elastic.co/t/index-date-math-with-seconds/276161/5 "2021-06-17T12:48:59Z")

</div>

I was trying to use it as a naming pattern in my ILM's bootsrapping but I noticed other issues later when the lifecycle policy was trying to rollover the newly created bootstrapped index, with all date math options I tried. Seconds to days (I wanted to have a human readable rolled over index naming convention instead of -000001):

Index lifecycle error  
number\_format\_exception: For input string: "ss}}"

Index lifecycle error  
number\_format\_exception: For input string: "mm}}"

Index lifecycle error  
number\_format\_exception: For input string: "dd}}"

---

<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:** [July 15, 2021, 12:49pm UTC](https://discuss.elastic.co/t/index-date-math-with-seconds/276161/6 "2021-07-15T12:49:31Z")

</div>

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