# How to dynamically add a column in the output and manipulate the date

**URL:** <https://discuss.elastic.co/t/how-to-dynamically-add-a-column-in-the-output-and-manipulate-the-date/102729>\
**Category:** Logstash\
**Created:** [October 4, 2017, 3:37pm UTC](https://discuss.elastic.co/t/how-to-dynamically-add-a-column-in-the-output-and-manipulate-the-date/102729 "2017-10-04T15:37:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssagarwal17](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@ssagarwal17](https://discuss.elastic.co/u/ssagarwal17)\
**Post date:** [October 4, 2017, 3:37pm UTC](https://discuss.elastic.co/t/how-to-dynamically-add-a-column-in-the-output-and-manipulate-the-date/102729/1 "2017-10-04T15:37:22Z")

</div>

How can i dynamically pass the date in the query 'Statment' and also use the same date as a output column?

I want the date to be 2 days behind the execution date

input {  
jdbc {  
jdbc\_driver\_library =\> "sqljdbc42.jar"  
jdbc\_driver\_class =\> "com.microsoft.sqlserver.jdbc.SQLServerDriver"  
jdbc\_connection\_string =\> "\*\*\*\*\*\*\*_**"  
jdbc\_user =\> ''  
jdbc\_password =\> '**'  
schedule =\> "_ \* \* \* \*"  
statement =\> " EXEC PROCEDURE\_NAME @date = '20170928' "  
}  
}  
filter {  
grok {  
match =\> { "message" =\> "%{COMBINEDAPACHELOG}"}  
}  
date {  
match =\> ["@timestamp", "ISO8601"]  
}  
}  
output {  
stdout { codec =\> rubydebug }  
influxdb {  
allow\_time\_override =\> 'true'  
data\_points =\> { "time" =\> "@timestamp" }  
send\_as\_tags =\> ["account\_name"]  
use\_event\_fields\_for\_data\_points =\> true  
host =\> "localhost"  
}  
}

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [October 5, 2017, 5:25am UTC](https://discuss.elastic.co/t/how-to-dynamically-add-a-column-in-the-output-and-manipulate-the-date/102729/2 "2017-10-05T05:25:01Z")

</div>

You could pass the desired date as an environment variable and reference that in your plugins.

[https://www.elastic.co/guide/en/logstash/current/environment-variables.html](https://www.elastic.co/guide/en/logstash/current/environment-variables.html)

---

<div class="post-metadata">

**Author:** ![ssagarwal17](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@ssagarwal17](https://discuss.elastic.co/u/ssagarwal17)\
**Post date:** [October 5, 2017, 9:28am UTC](https://discuss.elastic.co/t/how-to-dynamically-add-a-column-in-the-output-and-manipulate-the-date/102729/3 "2017-10-05T09:28:23Z")

</div>

Ok but i want it to change everyday like if its '5th Oct' then I want the value of the variable to be '3rd Oct' and i want it to be updated everyday. Is there a way I can do this?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [October 5, 2017, 11:17am UTC](https://discuss.elastic.co/t/how-to-dynamically-add-a-column-in-the-output-and-manipulate-the-date/102729/4 "2017-10-05T11:17:51Z")

</div>

Not without restarting Logstash, no.

---

<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 2, 2017, 11:17am UTC](https://discuss.elastic.co/t/how-to-dynamically-add-a-column-in-the-output-and-manipulate-the-date/102729/5 "2017-11-02T11:17:58Z")

</div>

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