# How to store date format as Simple date format instead of Timstamp while indexing

**URL:** https://discuss.elastic.co/t/how-to-store-date-format-as-simple-date-format-instead-of-timstamp-while-indexing/190466
**Category:** Elasticsearch
**Created:** [July 15, 2019, 8:42am UTC](https://discuss.elastic.co/t/how-to-store-date-format-as-simple-date-format-instead-of-timstamp-while-indexing/190466 "2019-07-15T08:42:45Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Lokesh\_Gorrela](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lokesh_gorrela/32/50127_2.png) [@Lokesh\_Gorrela](https://discuss.elastic.co/u/Lokesh_Gorrela)
#### Post date: [July 15, 2019, 8:42am UTC](https://discuss.elastic.co/t/how-to-store-date-format-as-simple-date-format-instead-of-timstamp-while-indexing/190466/1 "2019-07-15T08:42:46Z")

</div>

In my table in database , date column having **2018-07-09 00:00:00 format** date, but while indexing that date, It is stored as timestamp in elasticsearch. How I can store **04-20-2019 (Simple date format)** instead of **timestamp** in elasticsearch.

Anyone knows about this requirement please give reply to me.

Thanks  
Lokesh

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 15, 2019, 9:41am UTC](https://discuss.elastic.co/t/how-to-store-date-format-as-simple-date-format-instead-of-timstamp-while-indexing/190466/2 "2019-07-15T09:41:15Z")

</div>

You need to change what you are sending to elasticsearch if you want to have it in the `_source` field.

May be describe how you are injecting data and we could propose solutions?

---

<div class="post-metadata">

### Author: ![Lokesh\_Gorrela](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lokesh_gorrela/32/50127_2.png) [@Lokesh\_Gorrela](https://discuss.elastic.co/u/Lokesh_Gorrela)
#### Post date: [July 15, 2019, 9:55am UTC](https://discuss.elastic.co/t/how-to-store-date-format-as-simple-date-format-instead-of-timstamp-while-indexing/190466/3 "2019-07-15T09:55:37Z")

</div>

Hi

Thanks for your response.

I passed date value as **Mon Jul 15 12:15:59 IST 2019** in this format for indexing a document. After indexed a document it stored date as **20190615182947** this timestamp format. But I want to store date as simple date format(MM-DD-YYYY).

Please give any suggestions for my requirement.

Thanks  
Lokesh

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 15, 2019, 1:23pm UTC](https://discuss.elastic.co/t/how-to-store-date-format-as-simple-date-format-instead-of-timstamp-while-indexing/190466/4 "2019-07-15T13:23:18Z")

</div>

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<div class="post-metadata">

### Author: ![Lokesh\_Gorrela](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lokesh_gorrela/32/50127_2.png) [@Lokesh\_Gorrela](https://discuss.elastic.co/u/Lokesh_Gorrela)
#### Post date: [July 15, 2019, 1:42pm UTC](https://discuss.elastic.co/t/how-to-store-date-format-as-simple-date-format-instead-of-timstamp-while-indexing/190466/5 "2019-07-15T13:42:32Z")

</div>

**This is my mapping:**

"modified" : {  
"type" : "date",  
"store" : true,  
"format" : "yyyyMMddHHmmss"  
},  
"modified\_sortable" : {  
"type" : "long",  
"store" : true  
},  
"mybookName\_en\_US" : {  
"type" : "text",  
"store" : true,  
"term\_vector" : "with\_positions\_offsets",  
"analyzer" : "english"  
},  
"name" : {  
"type" : "text",  
"store" : true  
},

**This is my documents in elastic search:**

{"uid":"20100\_spellCheckWord\_fWUSdV4flcavJZzNWOj4Ew==","companyId":"20100","groupId":"0","spellCheckWord\_en\_US":"smith","languageId":"en\_US","priority":"0.0","type":"spellChecker"}},{"\_index":"liferay-20100","\_type":"LiferayDocumentType","\_id":"com.liferay.docs.guestbook.model.Entry\_PORTLET\_80202","\_score":6.8558645,"\_source":{"entryClassPK":"80202","publishDate\_sortable":0,"groupId":"20127","priority\_sortable":0.0," **publishDate":"19700101053000","guestbookName\_en\_US":"Main","createDate\_sortable":1563190379336,"uid":"com.liferay.docs.guestbook.model.Entry\_PORTLET\_80202","groupRoleId":"20127-20115","scopeGroupId":"20127","modified":"20190715170259","modified\_sortable":1563190379420,"expirationDate\_sortable":9223372036854775807** ,"email":"smith@gmail.com","createDate":"20190715170259","expirationDate":"99950812133000","content\_en\_US":"H}

In the above document date field is stored as a Timestamp format (19700101053000) . but I need to store date format as (MM/DD/YYYY) instead of Timestamp.

Please give a suggestion for my requirement.

Thanks  
Lokesh

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 15, 2019, 4:28pm UTC](https://discuss.elastic.co/t/how-to-store-date-format-as-simple-date-format-instead-of-timstamp-while-indexing/190466/6 "2019-07-15T16:28:02Z")

</div>

This works for me:

```auto
DELETE test
PUT test
{
  "mappings": {
    "properties": {
      "date": {
        "type": "date",
        "format": "MM/DD/YYYY"
      }
    }
  }
}
PUT test/_doc/1
{
  "date": "12/26/1971"
}

```

If you can't make it work, please provide a similar script to show what the problem is.

---

<div class="post-metadata">

### Author: ![Lokesh\_Gorrela](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lokesh_gorrela/32/50127_2.png) [@Lokesh\_Gorrela](https://discuss.elastic.co/u/Lokesh_Gorrela)
#### Post date: [July 18, 2019, 6:42am UTC](https://discuss.elastic.co/t/how-to-store-date-format-as-simple-date-format-instead-of-timstamp-while-indexing/190466/7 "2019-07-18T06:42:28Z")

</div>

Hi

Thanks for your reply.

---

<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: [August 15, 2019, 6:42am UTC](https://discuss.elastic.co/t/how-to-store-date-format-as-simple-date-format-instead-of-timstamp-while-indexing/190466/8 "2019-08-15T06:42:33Z")

</div>

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