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
Get Updates on the Splunk Community!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...