# Comparison (\<) not supported on datetime fields anymore since upgrade to 6.1

**URL:** https://discuss.elastic.co/t/comparison-not-supported-on-datetime-fields-anymore-since-upgrade-to-6-1/118008
**Category:** Elasticsearch
**Created:** [February 1, 2018, 11:34am UTC](https://discuss.elastic.co/t/comparison-not-supported-on-datetime-fields-anymore-since-upgrade-to-6-1/118008 "2018-02-01T11:34:58Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![stemps](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stemps/32/27242_2.png) [@stemps](https://discuss.elastic.co/u/stemps)
#### Post date: [February 1, 2018, 11:34am UTC](https://discuss.elastic.co/t/comparison-not-supported-on-datetime-fields-anymore-since-upgrade-to-6-1/118008/1 "2018-02-01T11:34:58Z")

</div>

I have a scripted field that looks something like this:

```auto
(doc['actual_time'].value < doc['expected_time'].value) ? 1 : 0

```

Since the upgrade to 6.1 I'm getting the following error:

```auto
caused_by":{"type":"class_cast_exception","reason":"Cannot apply [<] operation to types [org.joda.time.MutableDateTime] and [org.joda.time.MutableDateTime]."

```

The error message is rather confusing, as accoriding to [http://joda-time.sourceforge.net/apidocs/org/joda/time/MutableDateTime.html](http://joda-time.sourceforge.net/apidocs/org/joda/time/MutableDateTime.html) The `MutableDateTime` class implements `Comparable` and should therefore support `<` comparisons.

What's the correct way to compare timestamp fields in 6.1?

Thanks in advance,  
Simon

---

<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: [February 1, 2018, 5:40pm UTC](https://discuss.elastic.co/t/comparison-not-supported-on-datetime-fields-anymore-since-upgrade-to-6-1/118008/2 "2018-02-01T17:40:20Z")

</div>

Can you call then `getMillis()`?

[http://joda-time.sourceforge.net/apidocs/org/joda/time/base/BaseDateTime.html#getMillis()](http://joda-time.sourceforge.net/apidocs/org/joda/time/base/BaseDateTime.html#getMillis())

---

<div class="post-metadata">

### Author: ![stemps](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stemps/32/27242_2.png) [@stemps](https://discuss.elastic.co/u/stemps)
#### Post date: [February 5, 2018, 9:47am UTC](https://discuss.elastic.co/t/comparison-not-supported-on-datetime-fields-anymore-since-upgrade-to-6-1/118008/3 "2018-02-05T09:47:18Z")

</div>

Yep, that does it as a workaround. Thanks! 😀

---

<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 5, 2018, 9:47am UTC](https://discuss.elastic.co/t/comparison-not-supported-on-datetime-fields-anymore-since-upgrade-to-6-1/118008/4 "2018-03-05T09:47:56Z")

</div>

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