Dashboards & Visualizations

How to pass the date parameter in a query

aditsss
Motivator

Hi Everyone,

I have one requirement:

I have one date drop down like this:

<input type="time" token="field1">
<label>Date/Time</label>
<default>
<earliest>-7d@d</earliest>
<latest>now</latest>
</default>
</input>

And one panel query as below:

I need to know how can I pass $field1.earliest$ and $field1.latest$ in nowdate.(highlighted in bold)

<chart>
<search>
<query>|inputlookup JOB_MDJX_CS_EXTR_STATS_2.csv|append [ inputlookup JOB_MDJX_CS_EXTR_STATS_2_E2.csv]|append [ inputlookup JOB_MDJX_CS_EXTR_STATS_2_E3.csv]|where Environment="$Env$"|where JOBFLOW_ID LIKE "%$Src_Jb_Id$%"|eval Run_date1="20".RUNDATE2
|eval Run_Date=strptime(Run_date1,"%Y%m%d")
|eval nowdate=relative_time(now(), "-7d@d")|fieldformat nowdate=strftime(nowdate,"%d/%b/%Y")
|fieldformat Run_Date=strftime(Run_Date,"%d/%b/%Y")
|where Run_Date&gt;=nowdate|stats sum(REC_COUNT) by Run_Date</query>
<earliest>$field1.earliest$</earliest>
<latest>$field1.latest$</latest>

Labels (3)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try this:

<chart>
<search>
<query>|inputlookup JOB_MDJX_CS_EXTR_STATS_2.csv|append [ inputlookup JOB_MDJX_CS_EXTR_STATS_2_E2.csv]|append [ inputlookup JOB_MDJX_CS_EXTR_STATS_2_E3.csv]|where Environment="$Env$"|where JOBFLOW_ID LIKE "%$Src_Jb_Id$%"|eval Run_date1="20".RUNDATE2
|eval Run_Date=strptime(Run_date1,"%Y%m%d")
|eval nowdate=relative_time(now(), "$field1.earliest$")|fieldformat nowdate=strftime(nowdate,"%d/%b/%Y")
|fieldformat Run_Date=strftime(Run_Date,"%d/%b/%Y")
|where Run_Date&gt;=nowdate|stats sum(REC_COUNT) by Run_Date</query>
<earliest>$field1.earliest$</earliest>
<latest>$field1.latest$</latest>

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Try this:

<chart>
<search>
<query>|inputlookup JOB_MDJX_CS_EXTR_STATS_2.csv|append [ inputlookup JOB_MDJX_CS_EXTR_STATS_2_E2.csv]|append [ inputlookup JOB_MDJX_CS_EXTR_STATS_2_E3.csv]|where Environment="$Env$"|where JOBFLOW_ID LIKE "%$Src_Jb_Id$%"|eval Run_date1="20".RUNDATE2
|eval Run_Date=strptime(Run_date1,"%Y%m%d")
|eval nowdate=relative_time(now(), "$field1.earliest$")|fieldformat nowdate=strftime(nowdate,"%d/%b/%Y")
|fieldformat Run_Date=strftime(Run_Date,"%d/%b/%Y")
|where Run_Date&gt;=nowdate|stats sum(REC_COUNT) by Run_Date</query>
<earliest>$field1.earliest$</earliest>
<latest>$field1.latest$</latest>
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...