<?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: date generation is wrong using gentimes in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354194#M104836</link>
    <description>&lt;P&gt;@angelinealex can you try the following search and check results?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-365 end=-0 increment=1d 
| eval Date=strftime(starttime,"%Y-%m-%d") 
| reverse
| fields Date
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 15 Mar 2018 17:38:04 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2018-03-15T17:38:04Z</dc:date>
    <item>
      <title>date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354187#M104829</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am using below code snippet to generate previous 12 months.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| gentimes start=-365 end=-0 increment=0d&lt;BR /&gt;
| eval Date=strftime(starttime,"%Y-%m-%d")&lt;BR /&gt;
|sort Date | reverse&lt;BR /&gt;
| table Date&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I see two problems here,&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;its generating 2017-11-05 twice&lt;/LI&gt;
&lt;LI&gt;its missing 2018-03-11&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;What am I missing? Please help.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 04:38:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354187#M104829</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-03-15T04:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354188#M104830</link>
      <description>&lt;P&gt;Your query seems ok. I run that query and it giving me proper 365 results.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 04:45:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354188#M104830</guid>
      <dc:creator>p_gurav</dc:creator>
      <dc:date>2018-03-15T04:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354189#M104831</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;

&lt;P&gt;I checked the same code but it's giving the correct result. It's printing 2017-11-05 once and 2018-03-11 does exist.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 04:50:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354189#M104831</guid>
      <dc:creator>MousumiChowdhur</dc:creator>
      <dc:date>2018-03-15T04:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354190#M104832</link>
      <description>&lt;P&gt;ahh ok.. then why i am getting wrong result with duplicate date and missing date. Any guess?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 04:58:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354190#M104832</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-03-15T04:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354191#M104833</link>
      <description>&lt;P&gt;ahh ok.. then why i am getting wrong result with duplicate date and missing date. Any guess?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 04:58:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354191#M104833</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-03-15T04:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354192#M104834</link>
      <description>&lt;P&gt;Try rerunning search, if still it gives duplicates use &lt;CODE&gt;dedup&lt;/CODE&gt; command.&lt;/P&gt;

&lt;P&gt;Also use below query :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-365 end=-0 increment=0d | eval Date=strftime(starttime,"%Y-%m-%d") |sort - Date| table Date
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Mar 2018 05:01:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354192#M104834</guid>
      <dc:creator>p_gurav</dc:creator>
      <dc:date>2018-03-15T05:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354193#M104835</link>
      <description>&lt;P&gt;The above query resulted the same. If I use dedup command then i am not getting duplicate date. But still its missing 2018-03-11.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 16:04:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354193#M104835</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-03-15T16:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354194#M104836</link>
      <description>&lt;P&gt;@angelinealex can you try the following search and check results?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-365 end=-0 increment=1d 
| eval Date=strftime(starttime,"%Y-%m-%d") 
| reverse
| fields Date
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Mar 2018 17:38:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354194#M104836</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-03-15T17:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354195#M104837</link>
      <description>&lt;P&gt;I get the same result for the above query as well.&lt;/P&gt;

&lt;P&gt;I figured out the problem. but looking for the solution.&lt;BR /&gt;
Because of day light saving changes its duplicating 5th Nov, 2017 and missing 11th Mar, 2018.&lt;/P&gt;

&lt;P&gt;I am in PST timezone.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 18:42:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354195#M104837</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-03-15T18:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354196#M104838</link>
      <description>&lt;P&gt;@angelinealex First off... "good catch". I think you have found a bug with &lt;CODE&gt;gentimes&lt;/CODE&gt; command. You should add bug tag to this question and also report to Splunk Support if you have valid Splunk Entitlement.&lt;/P&gt;

&lt;P&gt;Meanwhile, you can try the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-365 end=-0 increment=1d
| eval Date=strftime(starttime,"%Y-%m-%d")
| fields Date
| dedup Date
| append [| makeresults | eval Date="2018-03-11" | fields - _time]
| sort Date
| reverse
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Mar 2018 02:50:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354196#M104838</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-03-16T02:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354197#M104839</link>
      <description>&lt;P&gt;This gives my correct result. But i cant hard code March 11 since it changes every year.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Mar 2018 01:36:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354197#M104839</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-03-17T01:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354198#M104840</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;    | gentimes start=1/16/17 end=-0 increment=0d 
    | eval Date=strftime(starttime,"%Y-%m-%d") 
    | sort Date 
    | reverse 
    | table Date 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above sample code gives me the proper result.. i mean without duplicate and missing date from 1/16/17. But how do i pass the dynamic date to &lt;STRONG&gt;start&lt;/STRONG&gt;?&lt;BR /&gt;
Daily I should get previous 12 months dates.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Mar 2018 01:46:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354198#M104840</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-03-17T01:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354199#M104841</link>
      <description>&lt;P&gt;Following two work (Starting with Jan/Feb)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start="01/16/2017" end=-0 increment=0d
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start="02/16/2017" end=-0 increment=0d
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But following does not (starting with March). If you try previous 12 month dates you will have a date in March which gives same issue as what you have noticed. Definitely a BUG with gentimes command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start="03/16/2017" end=-0 increment=0d
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Mar 2018 03:49:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354199#M104841</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-03-17T03:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354200#M104842</link>
      <description>&lt;P&gt;@angelinealex, you can use &lt;CODE&gt;map&lt;/CODE&gt; to get the first day of last year i.e. &lt;CODE&gt;01/01/2017&lt;/CODE&gt; and then pass to &lt;CODE&gt;gentimes&lt;/CODE&gt; to get all the dates. Finally after &lt;CODE&gt;reverse&lt;/CODE&gt;, you can retain only first 365 results using &lt;CODE&gt;head 365&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval startDateLastYear=strftime(relative_time(_time,"-1y@y"),"%m/%d/%Y")
| fields - _time
| map search="| gentimes start=\"$startDateLastYear$\" end=-0 increment=0d 
| eval Date=strftime(starttime,\"%Y-%m-%d\") 
| sort Date 
| reverse 
| table Date
| head 365"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also try the following dashboard code on similar lines to set the token for first day of last year i.e. &lt;CODE&gt;01/01/2017&lt;/CODE&gt; and then pass on the token to search query with &lt;CODE&gt;gentimes&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard&amp;gt;
  &amp;lt;label&amp;gt;gentimes last one year daylight saving issue&amp;lt;/label&amp;gt;
  &amp;lt;search&amp;gt;
    &amp;lt;query&amp;gt;| makeresults
| eval startDateLastYear=strftime(relative_time(_time,"-1y@y"),"%m/%d/%Y")
| fields - _time
    &amp;lt;/query&amp;gt;
    &amp;lt;earliest&amp;gt;-1s@s&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;@s&amp;lt;/latest&amp;gt;
    &amp;lt;done&amp;gt;
      &amp;lt;set token="tokStartDate"&amp;gt;$result.startDateLastYear$&amp;lt;/set&amp;gt;
    &amp;lt;/done&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| gentimes start="$tokStartDate$" end=-0 increment=0d 
| eval Date=strftime(starttime,"%Y-%m-%d") 
| sort Date 
| reverse 
| table Date
| head 365
          &amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please try out and confirm.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Mar 2018 04:02:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354200#M104842</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-03-17T04:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354201#M104843</link>
      <description>&lt;P&gt;saved search just worked like champ. Thank you very much for all your help&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 02:13:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354201#M104843</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-03-20T02:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354202#M104844</link>
      <description>&lt;P&gt;Glad you found this working mean while I have submitted a feedback on Splunk Docs that daylight saving start and end dates are not working as expected for &lt;CODE&gt;gentimes&lt;/CODE&gt; command!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 13:32:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354202#M104844</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-03-20T13:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354203#M104845</link>
      <description>&lt;P&gt;Great, Please let me also know if you get any response for the feedback &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 18:15:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354203#M104845</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-03-20T18:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354204#M104846</link>
      <description>&lt;P&gt;Splunk team has reopened an existing JIRA ticket for this issue JIRA # SPL-146219.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 11:04:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354204#M104846</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-03-29T11:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: date generation is wrong using gentimes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354205#M104847</link>
      <description>&lt;P&gt;Cool. Thank you for letting me know.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Mar 2018 03:07:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/date-generation-is-wrong-using-gentimes/m-p/354205#M104847</guid>
      <dc:creator>angelinealex</dc:creator>
      <dc:date>2018-03-30T03:07:13Z</dc:date>
    </item>
  </channel>
</rss>

