# Find Dates with offset

**URL:** <https://discuss.elastic.co/t/find-dates-with-offset/254244>\
**Category:** Elasticsearch\
**Created:** [November 4, 2020, 10:21am UTC](https://discuss.elastic.co/t/find-dates-with-offset/254244 "2020-11-04T10:21:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aquilino\_Viveiros](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aquilino_viveiros/32/56560_2.png) [@Aquilino\_Viveiros](https://discuss.elastic.co/u/Aquilino_Viveiros)\
**Post date:** [November 4, 2020, 10:21am UTC](https://discuss.elastic.co/t/find-dates-with-offset/254244/1 "2020-11-04T10:21:01Z")

</div>

Hello, hopefully someone can help me on this.

Consider the following mapping

```auto
{
  "dateOfBirth": {
    "properties": {
      "value": {
        "type": "date",
        "format": "dateOptionalTime"
      }
    }
  }
}

```

And for the above mapping i have the following data  
doc1 =\> dateOfBirth.value = 2020-10-21T08:00:00.000+00:00  
doc2 =\> dateOfBirth.value = 2020-01-05T10:00:00.000+02:00  
doc3 =\> dateOfBirth.value = 2020-09-15T08:00:00.000+05:00  
doc4 =\> dateOfBirth.value = 2020-05-03T11:00:00.000+02:00  
doc5 =\> dateOfBirth.value = 2020-10-31T12:00:00.000+03:00

Is is possible to build a query that can find all dates that have an offset, for example:  
`Find all dates with offset +02:00`

Thanks

---

<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:** [November 4, 2020, 10:25am UTC](https://discuss.elastic.co/t/find-dates-with-offset/254244/2 "2020-11-04T10:25:49Z")

</div>

I don't think you can with this mapping. I believe that the only way is to index the field as a `text` field in addition to the `date` type.

Better, I'd try to solve that problem at index time by parsing the text on the client side or using an ingest pipeline with a Script Processor and add a field like:

```
{
  "dateOfBirth": "2020-10-21T08:00:00.000+00:00",
  "hasOffset": false
}
```

---

<div class="post-metadata">

**Author:** ![Aquilino\_Viveiros](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aquilino_viveiros/32/56560_2.png) [@Aquilino\_Viveiros](https://discuss.elastic.co/u/Aquilino_Viveiros)\
**Post date:** [November 4, 2020, 10:45am UTC](https://discuss.elastic.co/t/find-dates-with-offset/254244/3 "2020-11-04T10:45:42Z")

</div>

Thanks for the quick reply.  
We were avoiding changing the mapping (live system), but as per your reply, we have no other choice.

---

<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:** [December 2, 2020, 10:45am UTC](https://discuss.elastic.co/t/find-dates-with-offset/254244/4 "2020-12-02T10:45:50Z")

</div>

Closed on December 2, 2020, 10:45am UTC

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