# How to check Mapping field not have any value

**URL:** <https://discuss.elastic.co/t/how-to-check-mapping-field-not-have-any-value/326906>\
**Category:** Kibana\
**Created:** [March 3, 2023, 5:25am UTC](https://discuss.elastic.co/t/how-to-check-mapping-field-not-have-any-value/326906 "2023-03-03T05:25:43Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [March 3, 2023, 6:04am UTC](https://discuss.elastic.co/t/how-to-check-mapping-field-not-have-any-value/326906/2 "2023-03-03T06:04:08Z")

</div>

Hi @PappuSingh

Please format your code in the future ... you have to check if the field exists you can not get the `.value` on a field that does not exist

I thought we answered this here

> [@Subtraction between current date and doc created date](https://discuss.elastic.co/t/subtraction-between-current-date-and-doc-created-date/326405/4):
>
> Do you want Days in Integer or Float? Field Type Double long datenow = new Date().getTime(); long datewas = doc['@timestamp'].value.getMillis(); double days = (datenow - datewas) / 86400000.0; emit (days); Field Type Long long datenow = new Date().getTime(); long datewas = doc['@timestamp'].value.getMillis(); long days = (datenow - datewas) / 86400000; emit (days);

If you just want to check do something like this

```auto
if(doc['readyCreatedTime'].empty) {
  emit(0);
  return;
}

long datenow = new Date().getTime();
long datewas = doc['readyCreatedTime'].value.getMillis();
long days = (datenow - datewas) / 86400000;
emit (days);

```

---

_[View the full topic](https://discuss.elastic.co/t/how-to-check-mapping-field-not-have-any-value/326906)._
