Dashboards & Visualizations

How do you Increment the date by using a date token passed as an input?

sarahnazzar
Explorer

Increment the date by using date token passed as input

When we select a date as input from the multiselect, it should populate the next date/previous date with the date which I gave as input..
For example: If I select 11/1/2018 as my input, the result should be (11/1/2018 and 11/2/2018) or (10/31/2018 and 11/1/2018) and this result needs to be passed as an input to my panel using token..

Can anyone help me figure out how to do this?!

Thanks in Advance!!

Tags (2)
0 Karma
1 Solution

renjith_nair
Legend

@sarahnazzar,

You can fnd the relative time on the change event and assign to a token.

      <change>
        <eval token="before">relative_time(strptime($date$,"%m/%d/%Y"),"-1d@d")</eval>
        <eval token="after">relative_time(strptime($value$,"%m/%d/%Y"),"1d@d")</eval>
      </change>

See below a run anywhere example

<form >
  <label>Date Conversion</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="date">
      <label>Date</label>
      <choice value="11/01/2018">11/01/2018</choice>
      <choice value="10/31/2018">10/31/2018</choice>
      <change>
        <eval token="before">strftime(relative_time(strptime($date$,"%m/%d/%Y"),"-1d@d"),"%d-%m-%Y")</eval>
        <eval token="after">strftime(relative_time(strptime($value$,"%m/%d/%Y"),"1d@d"),"%d-%m-%Y")</eval>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        <h1> $before$    |  $after$</h1>
      </html>
    </panel>
  </row>
</form>
Happy Splunking!

View solution in original post

0 Karma

renjith_nair
Legend

@sarahnazzar,

You can fnd the relative time on the change event and assign to a token.

      <change>
        <eval token="before">relative_time(strptime($date$,"%m/%d/%Y"),"-1d@d")</eval>
        <eval token="after">relative_time(strptime($value$,"%m/%d/%Y"),"1d@d")</eval>
      </change>

See below a run anywhere example

<form >
  <label>Date Conversion</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="date">
      <label>Date</label>
      <choice value="11/01/2018">11/01/2018</choice>
      <choice value="10/31/2018">10/31/2018</choice>
      <change>
        <eval token="before">strftime(relative_time(strptime($date$,"%m/%d/%Y"),"-1d@d"),"%d-%m-%Y")</eval>
        <eval token="after">strftime(relative_time(strptime($value$,"%m/%d/%Y"),"1d@d"),"%d-%m-%Y")</eval>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        <h1> $before$    |  $after$</h1>
      </html>
    </panel>
  </row>
</form>
Happy Splunking!
0 Karma

sarahnazzar
Explorer

Thanks a lot!! The above solution is working fine.

0 Karma
Get Updates on the Splunk Community!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...