Dashboards & Visualizations

Why am I getting error "Invalid date" trying to set now as default value for the date time picker?

s_aria
New Member

Hi all,

I'm trying to set now value for a default setting:

    <input type="time" token="time" searchWhenChanged="true">
      <label></label>
      <default>
        <earliestTime>0</earliestTime>
        <latestTime>now</latestTime>
      </default>
      <change>
        <eval token="form.et">strftime('earliest', "%F")</eval>
        <eval token="form.lt">strftime('latest', "%F")</eval>
      </change>
    </input>

I keep getting an error when I try and run the query with default value for latest. Only in this case.

Any advice would be well received.

Thanks,
Sal

0 Karma

erwanlebaron
Engager

The issue came from the fact the format is done as "relative date".
Try to change

<eval token="form.et">strftime('earliest', "%F")</eval>

by

<eval token="form.et">strftime(relative_time(now(),'earliest'), "%F"</eval>
0 Karma

sundareshr
Legend

Should be earliest & latest

 <input type="time" token="time" searchWhenChanged="true">
       <label></label>
       <default>
         <earliest>0</earliestTime>
         <latest>now</latestTime>
       </default>
       <change>
         <eval token="form.et">strftime('earliest', "%F")</eval>
         <eval token="form.lt">strftime('latest', "%F")</eval>
       </change>
     </input>
0 Karma

s_aria
New Member

also replacing the tag name the error persist.

Thanks,
Sal

0 Karma

frobinson_splun
Splunk Employee
Splunk Employee

Hi @s.aria,
Could you try substituting "earliest" and "latest" for these two tags? For one, "earliestTime" and "latestTime" are deprecated and 'earliest'/'latest' should be used instead. I also wonder if the difference in the tag name you are using (earliestTime) and the reference you are passing to the strftime function ('earliest'), might be causing an issue.

Hope this helps! Let me know if this does not fix the problem and we can keep discussing.

0 Karma

s_aria
New Member

Hi @frobinson

Thanks for the reply.
I tried replacing the tag name, but the error persist:
form.et=1970-01-01
form.lt=Invalid date

Thanks,
Sal

0 Karma

frobinson_splun
Splunk Employee
Splunk Employee

Hi Sal,
What search string are you using? Can you post it?

0 Karma

s_aria
New Member

Hi,

in a | dbquery ....... WHERE FIELD >= STR_TO_DATE('$form.lt$','%Y-%m-%d')

0 Karma
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...