# How to get date to format correctly

**URL:** <https://discuss.elastic.co/t/how-to-get-date-to-format-correctly/297818>\
**Category:** Elasticsearch\
**Tags:** transforms\
**Created:** [February 21, 2022, 10:56pm UTC](https://discuss.elastic.co/t/how-to-get-date-to-format-correctly/297818 "2022-02-21T22:56:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gentle\_ghost](https://avatars.discourse-cdn.com/v4/letter/g/ea5d25/32.png) [@gentle\_ghost](https://discuss.elastic.co/u/gentle_ghost)\
**Post date:** [February 21, 2022, 10:56pm UTC](https://discuss.elastic.co/t/how-to-get-date-to-format-correctly/297818/1 "2022-02-21T22:56:26Z")

</div>

Hello,

In transforms can you specify an index template for mappings? Or set the date format? My source index has a timestamp properly formatted using `strict_date_optional_time||epoch_millis`. When it goes to the transform index I lose the formatting. I have the following settings in a transform:

```auto

      "dest" : {
        "index" : "transform_test",
        "pipeline": "date_format_transform"

```

Where the pipeline date\_formatt\_transform turns the timestamp into `strict_date_optional_time||epoch_millis` However everytime I check the mappings of my new index my date is just "date" with no formatting:

```auto
        "timestamp" : {
          "type" : "date"
        },

```

I tried specifying the date formatting directly as well:

```
     "timestamp" : {
        "date_histogram" : {
          "field" : "timestamp",
          "format" : "strict_date_optional_time||epoch_millis",
          "calendar_interval" : "1d"
        }

```

But I get the error:

`[data_frame_date_histogram_group] unknown field [format]`

Please advise

---

<div class="post-metadata">

**Author:** ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)\
**Post date:** [February 22, 2022, 1:28am UTC](https://discuss.elastic.co/t/how-to-get-date-to-format-correctly/297818/2 "2022-02-22T01:28:15Z")

</div>

Hi,

You have to set the mappings of the destination index before the transform ingesting documents. If transform ingest documents before set mappings, field types are determined by Elasticsearch dynamically.

---

<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:** [March 22, 2022, 1:28am UTC](https://discuss.elastic.co/t/how-to-get-date-to-format-correctly/297818/3 "2022-03-22T01:28:31Z")

</div>

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