Hi, is it possible to format time picker value, e.g. $earliest$ and $latest$, in panel title? If i do something like this:
<title>Total access for department $d_name$ between $earliest$ and $latest$</title>
It gives raw time format, or the relative values like -4d@d. We hope to print the values in yyyymmdd HH:MM:SS in title. Please help.
Thanks a lot.
/ST Wong
Can you first try to evaluate the string you are interested in as tokens using eval
and then use those tokens in the title. Say the token of your timepicker is myTimepicker
then try something like this and see if it works out:
<eval token="fromDate">strftime($myTimepicker.earliest$,"%Y%m/%d %H:%M:%S")</eval>
<eval token="toDate">strftime($myTimepicker.latest$, "%Y%m/%d %H:%M:%S")</eval>
And then later use $fromDate$
and $toDate$
in the panel title.
Hi all,
Thanks for your help. Both ways work with custom time range is selected. However, strftime doesn't understand relative time specifiers like -30m@m, which is used quite frequently by our users.
Thanks again.
@stwong - It looks like you found a solution to your question? If one of them provided a working solution, please don't forget to click "Accept" below the best answer to resolve this post so that it can easily be found by other users in the same situation. Don’t forget to upvote anything that was helpful too. Thanks!
Got it. Thanks.
You are welcome!
Try this runanywhere sample
<form>
<label>TobeDeleted</label>
<fieldset submitButton="false">
<input type="time" token="timerange" searchWhenChanged="true">
<label>Time Range</label>
<default>
<earliest>-15m</earliest>
<latest>now</latest>
</default>
</input>
</fieldset>
<search>
<query>| gentimes start=-1 | addinfo </query>
<earliest>$timerange.earliest$</earliest>
<latest>$timerange.latest$</latest>
<done>
<eval token="Tearliest">strftime($result.info_min_time$,"%F %T")</eval>
<eval token="Tlatest">strftime($result.info_max_time$,"%F %T")</eval>
</done>
</search>
<row>
<panel>
<table>
<title>Showing data between $Tearliest$ and $Tlatest$</title>
<search>
<query>|gentimes start=-1 | eval Message="Dummy Panel" | table Message </query>
<earliest>$timerange.earliest$</earliest>
<latest>$timerange.latest$</latest>
</search>
<option name="wrap">true</option>
<option name="rowNumbers">false</option>
<option name="dataOverlayMode">none</option>
<option name="drilldown">row</option>
<option name="count">10</option>
</table>
</panel>
</row>
</form>
Can you first try to evaluate the string you are interested in as tokens using eval
and then use those tokens in the title. Say the token of your timepicker is myTimepicker
then try something like this and see if it works out:
<eval token="fromDate">strftime($myTimepicker.earliest$,"%Y%m/%d %H:%M:%S")</eval>
<eval token="toDate">strftime($myTimepicker.latest$, "%Y%m/%d %H:%M:%S")</eval>
And then later use $fromDate$
and $toDate$
in the panel title.