# Logstash jdbc input plugin mongodb driver can not query time range

**URL:** <https://discuss.elastic.co/t/logstash-jdbc-input-plugin-mongodb-driver-can-not-query-time-range/269879>\
**Category:** Logstash\
**Created:** [April 12, 2021, 12:55pm UTC](https://discuss.elastic.co/t/logstash-jdbc-input-plugin-mongodb-driver-can-not-query-time-range/269879 "2021-04-12T12:55:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![john.zhang](https://avatars.discourse-cdn.com/v4/letter/j/c89c15/32.png) [@john.zhang](https://discuss.elastic.co/u/john.zhang)\
**Post date:** [April 12, 2021, 12:55pm UTC](https://discuss.elastic.co/t/logstash-jdbc-input-plugin-mongodb-driver-can-not-query-time-range/269879/1 "2021-04-12T12:55:13Z")

</div>

Hi,  
Please help . I want to search records in mongodb during 3 days.  
this is my logstash conf:

> input {  
> jdbc {  
> jdbc\_driver\_class =\> "com.dbschema.MongoJdbcDriver"  
> jdbc\_driver\_library =\> "/usr/share/logstash/logstash-core/lib/jars/mongojdbc3.1.jar"  
> jdbc\_connection\_string =\> "jdbc:mongodb://elk:123@192.168.1.245:27017/qisda"  
> jdbc\_user =\> ""  
> jdbc\_password =\> ""  
> schedule =\> "\* \* \* \* \*"
> 
> ```auto
> 
> ```

statement =\> "db.dataLog.find({createDate:{ $lte: ISODate(:sql\_last\_value) ,$gte: new Date(ISODate(:sql\_last\_value).getTime()-`3*24*60*60*1000`)} }, {"appendInfo.cutMap":0,\_id: 0})"

```auto
> last_run_metadata_path => "/logstash/.logstash_jdbc_last_run3"
> }

error message:

[2021-04-12T12:38:00,721][ERROR][logstash.inputs.jdbc][main][d06cde4a8042fd780069608da1616ae2542e70a4a1b47c36f6e4f1b79816728f] Java::JavaSql::SQLException:
 Un-parsable date: 1614398400000 Configured formats: yyyy-MM-dd,dd-MM-yyyy,dd.MM.yyyy,d.MM.yyyy,dd/MM/yyyy,yyyy.MM.dd,M/d/yyyy: 
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")

I dont know how to resolve it , any advice!
```

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 12, 2021, 3:43pm UTC](https://discuss.elastic.co/t/logstash-jdbc-input-plugin-mongodb-driver-can-not-query-time-range/269879/2 "2021-04-12T15:43:43Z")

</div>

That is not really a logstash question. In your SQL your are doing date manipulations. You are passing a timestamp which is milliseconds since the epoch, to something that expects one of yyyy-MM-dd, dd-MM-yyyy, dd.MM.yyyy, d.MM.yyyy, dd/MM/yyyy, yyyy.MM.dd, M/d/yyyy...

I do not know whether that something is MongoDB itself, or whatever is evaluating the expressions in SQL (not sure if that is done in the DB or the driver).

---

<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:** [May 10, 2021, 3:43pm UTC](https://discuss.elastic.co/t/logstash-jdbc-input-plugin-mongodb-driver-can-not-query-time-range/269879/3 "2021-05-10T15:43:43Z")

</div>

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