# Painless - compare data fields without seconds

**URL:** <https://discuss.elastic.co/t/painless-compare-data-fields-without-seconds/210378>\
**Category:** Elasticsearch\
**Created:** [December 3, 2019, 3:06pm UTC](https://discuss.elastic.co/t/painless-compare-data-fields-without-seconds/210378 "2019-12-03T15:06:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AstroSlazak](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@AstroSlazak](https://discuss.elastic.co/u/AstroSlazak)\
**Post date:** [December 3, 2019, 3:06pm UTC](https://discuss.elastic.co/t/painless-compare-data-fields-without-seconds/210378/1 "2019-12-03T15:06:01Z")

</div>

Hi,  
I would like to comapre two data fields, but i don't want to be precisely to second, minutes are enough to me.  
My data fields looks like this: "Dec 2, 2019 @ 08:34:18.000" and my painless is:

> doc['arrivaltime'].value.isAfter(doc['schedulearrival'].value

How can i get rid of seconds ?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 4, 2019, 1:08pm UTC](https://discuss.elastic.co/t/painless-compare-data-fields-without-seconds/210378/2 "2019-12-04T13:08:56Z")

</div>

you can to set the second to zero with the `.withSecond(0)` method of one of the java time classes (I have not tested this, if this requires some more conversion before that).

---

<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:** [January 1, 2020, 1:09pm UTC](https://discuss.elastic.co/t/painless-compare-data-fields-without-seconds/210378/3 "2020-01-01T13:09:13Z")

</div>

Closed on January 1, 2020, 1:09pm UTC

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