# Problem with query date elastichsearch with php

**URL:** https://discuss.elastic.co/t/problem-with-query-date-elastichsearch-with-php/253336
**Category:** Elasticsearch
**Created:** [October 26, 2020, 3:43pm UTC](https://discuss.elastic.co/t/problem-with-query-date-elastichsearch-with-php/253336 "2020-10-26T15:43:55Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![joseantonio.sanchez](https://avatars.discourse-cdn.com/v4/letter/j/ee7513/32.png) [@joseantonio.sanchez](https://discuss.elastic.co/u/joseantonio.sanchez)
#### Post date: [October 26, 2020, 3:43pm UTC](https://discuss.elastic.co/t/problem-with-query-date-elastichsearch-with-php/253336/1 "2020-10-26T15:43:56Z")

</div>

good afternoon,

I am making a query from php to elasticsearch,  
I give you some parameters

$params = [  
'scroll' =\> '30s', // how long between scroll requests. should be small!  
'size' =\> 300, // how many results _per shard_ you want back  
'index' =\> $module,  
'\_source' =\> $return\_values,  
'body' =\> [  
'query' =\> [  
"bool" =\> [  
"must" =\> [  
[  
'range' =\> [  
'fecha\_inicio' =\> [  
"lt" =\> $fecha\_inicio  
]  
]  
],  
[  
'range' =\> [  
'fecha\_fin' =\> [  
"lte" =\> $fecha\_fin,  
"gte" =\> $fecha\_inicio  
]  
]  
],  
]  
]  
]  
],  
];

but when I do the query it returns values that are not within the range that I put.

I had also put "format" =\> "yyyy-MM-dd", since the date I sent you has that format, and the fecha\_inicio mapping in elastichsearch

"fecha\_inicio": {  
"type": "date",  
"format": "yyyy-MM-DD"  
},  
"fecha\_fin": {  
"type": "date",  
"format": "yyyy-MM-DD"  
},

I dont know what happen for the elasticsearch dont send me the correct information

---

<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: [November 23, 2020, 3:44pm UTC](https://discuss.elastic.co/t/problem-with-query-date-elastichsearch-with-php/253336/2 "2020-11-23T15:44:00Z")

</div>

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