# Format date field as a string?

**URL:** https://discuss.elastic.co/t/format-date-field-as-a-string/222733
**Category:** Logstash
**Created:** [March 9, 2020, 2:46pm UTC](https://discuss.elastic.co/t/format-date-field-as-a-string/222733 "2020-03-09T14:46:20Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![macau](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/macau/32/64091_2.png) [@macau](https://discuss.elastic.co/u/macau)
#### Post date: [March 9, 2020, 2:46pm UTC](https://discuss.elastic.co/t/format-date-field-as-a-string/222733/1 "2020-03-09T14:46:20Z")

</div>

I would like to create a new string field from a date field (@timestamp) in the format "yyyy-MM-dd" (e.g. 2020-12-31) - is that possible with Logstash?

---

<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: [March 9, 2020, 2:54pm UTC](https://discuss.elastic.co/t/format-date-field-as-a-string/222733/2 "2020-03-09T14:54:13Z")

</div>

Read through [this thread](https://discuss.elastic.co/t/date-change-day-and-month-position/221606/12).

---

<div class="post-metadata">

### Author: ![macau](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/macau/32/64091_2.png) [@macau](https://discuss.elastic.co/u/macau)
#### Post date: [March 9, 2020, 3:47pm UTC](https://discuss.elastic.co/t/format-date-field-as-a-string/222733/3 "2020-03-09T15:47:52Z")

</div>

Aha, so only by jumping to ruby? Not with mutate?

Is there instead a way to zero-pad a number without ruby?

---

<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: [March 9, 2020, 4:36pm UTC](https://discuss.elastic.co/t/format-date-field-as-a-string/222733/4 "2020-03-09T16:36:05Z")

</div>

You cannot convert a date using mutate. I do not think you can zero pad without using ruby.

---

<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: [April 6, 2020, 4:36pm UTC](https://discuss.elastic.co/t/format-date-field-as-a-string/222733/5 "2020-04-06T16:36:08Z")

</div>

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