# How to express today's date in sql in logstash

**URL:** https://discuss.elastic.co/t/how-to-express-todays-date-in-sql-in-logstash/168319
**Category:** Logstash
**Created:** [February 14, 2019, 2:25am UTC](https://discuss.elastic.co/t/how-to-express-todays-date-in-sql-in-logstash/168319 "2019-02-14T02:25:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![scorpioy1](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@scorpioy1](https://discuss.elastic.co/u/scorpioy1)
#### Post date: [February 14, 2019, 2:25am UTC](https://discuss.elastic.co/t/how-to-express-todays-date-in-sql-in-logstash/168319/1 "2019-02-14T02:25:28Z")

</div>

How should I express today's date in sql in logstash?  
I tried this and it doesn't work. It throws error saying cannot convert VARCHAR '%{YYYY.DD.dd}' to DATE.  
Please help.

input {  
jdbc {  
....  
statement =\> "select \* from ... where date\_col=:'todayDate'  
parameters =\> { "todayDate" =\> "%{YYYY.DD.dd}" }  
....  
}  
}

---

<div class="post-metadata">

### Author: ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)
#### Post date: [February 15, 2019, 8:09pm UTC](https://discuss.elastic.co/t/how-to-express-todays-date-in-sql-in-logstash/168319/2 "2019-02-15T20:09:27Z")

</div>

It's typically easier to do this using a function that is supported by your database.

e.g., with postgres, if the `date_col`'s type were `date`, then you could use `WHERE date_col=CURRENT_DATE`

---

<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: [March 15, 2019, 8:09pm UTC](https://discuss.elastic.co/t/how-to-express-todays-date-in-sql-in-logstash/168319/3 "2019-03-15T20:09:28Z")

</div>

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