# Joda date time

**URL:** <https://discuss.elastic.co/t/joda-date-time/186653>\
**Category:** Elasticsearch\
**Created:** [June 20, 2019, 10:21am UTC](https://discuss.elastic.co/t/joda-date-time/186653 "2019-06-20T10:21:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![saranjeet](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@saranjeet](https://discuss.elastic.co/u/saranjeet)\
**Post date:** [June 20, 2019, 10:21am UTC](https://discuss.elastic.co/t/joda-date-time/186653/1 "2019-06-20T10:21:09Z")

</div>

```
{
  "from": 0,
  "size": 10000,
  "query": {
    "bool": {
      "must": [
        {
          "match_all": {
            "boost": 1
          }
        },
        {
          "bool": {
            "must": [
              {
                "script": {
                  "script": {
                    "source": "def v1,id; if( ((DateTime.now().millis-doc[108].value)/(1000.0 * 3600 * 24 * 30.5)) < 9 && doc[2515].value == 'yes') {v1 = 1} else {v1 = 0} if(doc['ctrycode'].value == 1 && v1 ==1 && doc[61].value >= 5) {id = 1} else if (v1 == 1 && doc['ctrycode'].value != 1) {id = 1} else {id = 0} id== 1",
                    "lang": "painless"
                  },
                  "boost": 1
                }
              }
            ],
            "adjust_pure_negative": true,
            "boost": 1
          }
        }
      ],
      "adjust_pure_negative": true,
      "boost": 1
    }
  },
  "_source": {
    "includes": [
      "msid"
    ],
    "excludes": []
  }
}

DateTime (Joda DateTime)is not working and throwing error  

"caused_by": {
            "type": "script_exception",
            "reason": "compile error",
            "script_stack": [
                "def v1,id; if( ((DateTime.now().millis-doc ...",
                " ^---- HERE"
            ],
            "script": "def v1,id; if( ((DateTime.now().millis-doc[108].value)/(1000.0 * 3600 * 24 * 30.5)) < 9 && doc[2515].value == 'yes') {v1 = 1} else {v1 = 0} if(doc['ctrycode'].value == 1 && v1 ==1 && doc[61].value >= 5) {id = 1} else if (v1 == 1 && doc['ctrycode'].value != 1) {id = 1} else {id = 0} id== 1",
            "lang": "painless",
            "caused_by": {
                "type": "illegal_argument_exception",
                "reason": "Variable [DateTime] is not defined."
            }
        }
    },
```

---

<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:** [June 20, 2019, 10:22am UTC](https://discuss.elastic.co/t/joda-date-time/186653/2 "2019-06-20T10:22:31Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.  
Please update your post.

Probably you need to use the fully qualified name for `DateTime` class (including its package name). But that's a guess.

---

<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:** [July 18, 2019, 10:22am UTC](https://discuss.elastic.co/t/joda-date-time/186653/3 "2019-07-18T10:22:44Z")

</div>

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