# How to use AND operator in Kibana scripted field

**URL:** <https://discuss.elastic.co/t/how-to-use-and-operator-in-kibana-scripted-field/89678>\
**Category:** Kibana\
**Created:** [June 16, 2017, 9:05am UTC](https://discuss.elastic.co/t/how-to-use-and-operator-in-kibana-scripted-field/89678 "2017-06-16T09:05:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gurveer\_Singh](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@Gurveer\_Singh](https://discuss.elastic.co/u/Gurveer_Singh)\
**Post date:** [June 16, 2017, 9:05am UTC](https://discuss.elastic.co/t/how-to-use-and-operator-in-kibana-scripted-field/89678/1 "2017-06-16T09:05:50Z")

</div>

Hi,

I am trying to use && operator in Kibana scripted field but it's not working. I am using following painless code.

def diff = new Date().getTime() - doc['OpenTime'].value;  
def daysdiff = diff / 1000 / 60 / 60 / 24;

if (daysdiff \>= 6) && (daysdiff \<= 10) {  
return "6 To 10 Days"  
} else {  
return "10+ Days"  
}

 ![](https://us1.discourse-cdn.com/elastic/original/3X/1/8/18f23bf741184075910698c69b189a4e797f1b80.PNG)

One thing more, is it possible to use **if elseif else** in painless? If yes, how?

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [June 17, 2017, 6:44am UTC](https://discuss.elastic.co/t/how-to-use-and-operator-in-kibana-scripted-field/89678/2 "2017-06-17T06:44:58Z")

</div>

it should be possible to use if/ else if/ else .... if not straight forward, with nesting if statements.

the and should also work, but your if syntax seems to be wrong

`if (CONDITION1 && CONDITION2)`, not `if (COND1) && (COND2)` (mind the parenthesis)

---

<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 15, 2017, 6:45am UTC](https://discuss.elastic.co/t/how-to-use-and-operator-in-kibana-scripted-field/89678/3 "2017-07-15T06:45:03Z")

</div>

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