# Add dynamic date range in CSV post url

**URL:** <https://discuss.elastic.co/t/add-dynamic-date-range-in-csv-post-url/342500>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-reporting\
**Created:** [September 7, 2023, 7:39am UTC](https://discuss.elastic.co/t/add-dynamic-date-range-in-csv-post-url/342500 "2023-09-07T07:39:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Atul\_Chadha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/atul_chadha/32/75469_2.png) [@Atul\_Chadha](https://discuss.elastic.co/u/Atul_Chadha)\
**Post date:** [September 7, 2023, 7:39am UTC](https://discuss.elastic.co/t/add-dynamic-date-range-in-csv-post-url/342500/1 "2023-09-07T07:39:05Z")

</div>

I am using ES 7.x and trying to add POST URL from CSV share feature into another system. Is there a way to add date range dynamically [Link here](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/query-dsl-range-query.html) because the url provided by UI has fixed date and we do not want to come to UI for link.  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/2/02f51df091fbc411aaeaf88fb76802c80977aed4.png)

To clarify, i am trying to add date range after i copy it over and reuse the same url time and again using range rather than fixed date it was created from.

---

<div class="post-metadata">

**Author:** ![Atul\_Chadha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/atul_chadha/32/75469_2.png) [@Atul\_Chadha](https://discuss.elastic.co/u/Atul_Chadha)\
**Post date:** [September 12, 2023, 4:32am UTC](https://discuss.elastic.co/t/add-dynamic-date-range-in-csv-post-url/342500/2 "2023-09-12T04:32:37Z")

</div>

Checking if any one has any thoughts on this ?

---

<div class="post-metadata">

**Author:** ![Atul\_Chadha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/atul_chadha/32/75469_2.png) [@Atul\_Chadha](https://discuss.elastic.co/u/Atul_Chadha)\
**Post date:** [September 15, 2023, 2:56pm UTC](https://discuss.elastic.co/t/add-dynamic-date-range-in-csv-post-url/342500/3 "2023-09-15T14:56:20Z")

</div>

I was able to do this using shell script and parse date using date command and formatting. The same is being sent as a variable in the API and works fine.  
CYEAR=`date -u -d "30 days ago" '+%Y' | xargs`  
PMONTH=`date -u -d "30 days ago" '+%m' | xargs`  
PDAY=`date -u -d "30 days ago" '+%d' | xargs`  
CMONTH=`date '+%m' | xargs`  
CDAY=`date '+%d' | xargs`

{CYEAR}-${PMONTH}-${PDAY}T18%3A30%3A00.000Z%27%2Clte%3A%27${CYEAR}-${CMONTH}-${CDAY}T

---

<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:** [October 13, 2023, 2:56pm UTC](https://discuss.elastic.co/t/add-dynamic-date-range-in-csv-post-url/342500/4 "2023-10-13T14:56:43Z")

</div>

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