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!

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to Officially Supported Splunk ...