<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Set time using data in token in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Set-time-using-data-in-token/m-p/676041#M231262</link>
    <description>&lt;LI-CODE lang="markup"&gt;| where _time = strptime(time_token,"%Y-%m-%d")&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 31 Jan 2024 10:55:17 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2024-01-31T10:55:17Z</dc:date>
    <item>
      <title>Set time using data in token</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-time-using-data-in-token/m-p/676033#M231259</link>
      <description>&lt;P&gt;I made a graph that send time data at click point.&lt;BR /&gt;I use "fieldformat" to change time data shown.&lt;BR /&gt;This is my code about time part at this graph.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;| &lt;FONT color="#3366FF"&gt;rename &lt;/FONT&gt;_time AS Date&lt;BR /&gt;| &lt;FONT color="#3366FF"&gt;fieldformat&lt;/FONT&gt; Date = &lt;FONT color="#FF00FF"&gt;strftime&lt;/FONT&gt;(Date,"%Y-%m-%d")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;So the token data send like this "2024-01-23"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to set the time with the data received from the token about another graph.&lt;BR /&gt;For example, If time_token send me "2024-01-23", I want to show only the data from 2024-01-23 in another graph.&lt;BR /&gt;I tried this code, but it not worked. (Maybe it cause about format changing)&lt;/P&gt;&lt;PRE&gt;| &lt;FONT color="#3366FF"&gt;where&lt;/FONT&gt; _time = time_token&lt;/PRE&gt;&lt;P&gt;How could I solve this problem?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2024 10:09:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-time-using-data-in-token/m-p/676033#M231259</guid>
      <dc:creator>Questioner</dc:creator>
      <dc:date>2024-01-31T10:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: Set time using data in token</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-time-using-data-in-token/m-p/676041#M231262</link>
      <description>&lt;LI-CODE lang="markup"&gt;| where _time = strptime(time_token,"%Y-%m-%d")&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 31 Jan 2024 10:55:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-time-using-data-in-token/m-p/676041#M231262</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-01-31T10:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Set time using data in token</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-time-using-data-in-token/m-p/676044#M231263</link>
      <description>&lt;P&gt;First, surround the token name with dollar signs, i.e., $time_token$. &amp;nbsp;Second, if _time in your second search is Splunk's built in event time, its value is epoch, and will never equal a string like "2024-01-23". &amp;nbsp;Third, when you rename _time in the first search to Date then use fieldformat on this field, you are only changing the display. &amp;nbsp;$time_token$ transmitted to the second search is still the original _time value, which is NOT the date value, but the precise event value in the first search. &amp;nbsp;As such, chances are extremely slim that the second search will find a match.&lt;/P&gt;&lt;P&gt;You need to rethink what value to send to the second search. &amp;nbsp;The solution depends very much on what are you doing with Date field in the first search and what exact value you are trying to match in the second search. &amp;nbsp;No one else knows those conditions but yourself. &amp;nbsp;So, you will need to describe them very clearly.&lt;/P&gt;&lt;P&gt;I will give you one example. &amp;nbsp;Suppose _time in your second search is event time, Date in the first search is just for display, and that you want to match calendar date between the first and second searches, even though the events' time of day is different. (These are big IFs. &amp;nbsp;Like I said, no one else knows what your use case is and how data look like.) &amp;nbsp;In this case, you can keep the first search, and work on the second search to match calendar date like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where relative_time(_time, "-0d@d") == relative_time($time_token$, "-0d@d")&lt;/LI-CODE&gt;&lt;P&gt;This is perhaps the most expressive way to implement the use case I exemplified above, although it is not the most semantic in accordance to your original design. &amp;nbsp;If you want to be semantical, both the first search and second search need a change.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2024 11:05:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-time-using-data-in-token/m-p/676044#M231263</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-01-31T11:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Set time using data in token</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Set-time-using-data-in-token/m-p/676362#M231330</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;What you wrote is similar to my situation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I solve this problem using different way (Notice that this wasn't the way to go).&lt;BR /&gt;But your answer made me aware of factors to think about.&lt;/P&gt;&lt;P&gt;Thank you for your helping!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 08:35:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Set-time-using-data-in-token/m-p/676362#M231330</guid>
      <dc:creator>Questioner</dc:creator>
      <dc:date>2024-02-02T08:35:29Z</dc:date>
    </item>
  </channel>
</rss>

