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>
---
What goes around comes around. If it helps, hit it with Karma 🙂

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>
---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

sarahnazzar
Explorer

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

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...