<?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: How do I localize date_mday? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-localize-date-mday/m-p/65878#M16342</link>
    <description>&lt;P&gt;I don't think you can, at least not easily.  The problem is that &lt;CODE&gt;date_mday&lt;/CODE&gt; and all the other &lt;CODE&gt;date_*&lt;/CODE&gt; fields are determined at index time.  So these are static values that cannot be shifted to adjust for timezone at search time.&lt;/P&gt;

&lt;P&gt;You can however build your own field that contains the day with an &lt;CODE&gt;eval&lt;/CODE&gt; command like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | eval mday=strftime("%d", _time) | chart ... by mday
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So from there you will probably get the exact same value that &lt;CODE&gt;date_mday&lt;/CODE&gt; already contains, so what you'll have to do is find the correct timezone offset and adjust for that manually.  For example, if are 1 hour off GMT, then you could use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | eval mday=strftime("%d", _time+3600)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you have different servers in different timezones that this gets more complicated.  You may be able to leverage the fact that &lt;CODE&gt;date_zone&lt;/CODE&gt; contains the timezone offset in minutes within your timezone calculations.  (It also contains the word "local", so'll have to filter that out, something like:   &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | eval tz_offset_secs=if(date_zone=="local", 0, date_zone*60)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Related question:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://answers.splunk.com/questions/4528/finding-your-local-timezone-with-eval" rel="nofollow"&gt;Finding your local timezone with eval?&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Thu, 07 Oct 2010 20:29:03 GMT</pubDate>
    <dc:creator>Lowell</dc:creator>
    <dc:date>2010-10-07T20:29:03Z</dc:date>
    <item>
      <title>How do I localize date_mday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-localize-date-mday/m-p/65877#M16341</link>
      <description>&lt;P&gt;When I use chart using date_mday as a parameter, it is in GMT. Is there any way to make this the date for my local time zone? &lt;/P&gt;</description>
      <pubDate>Thu, 07 Oct 2010 07:22:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-localize-date-mday/m-p/65877#M16341</guid>
      <dc:creator>zzztimbo</dc:creator>
      <dc:date>2010-10-07T07:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I localize date_mday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-localize-date-mday/m-p/65878#M16342</link>
      <description>&lt;P&gt;I don't think you can, at least not easily.  The problem is that &lt;CODE&gt;date_mday&lt;/CODE&gt; and all the other &lt;CODE&gt;date_*&lt;/CODE&gt; fields are determined at index time.  So these are static values that cannot be shifted to adjust for timezone at search time.&lt;/P&gt;

&lt;P&gt;You can however build your own field that contains the day with an &lt;CODE&gt;eval&lt;/CODE&gt; command like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | eval mday=strftime("%d", _time) | chart ... by mday
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So from there you will probably get the exact same value that &lt;CODE&gt;date_mday&lt;/CODE&gt; already contains, so what you'll have to do is find the correct timezone offset and adjust for that manually.  For example, if are 1 hour off GMT, then you could use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | eval mday=strftime("%d", _time+3600)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you have different servers in different timezones that this gets more complicated.  You may be able to leverage the fact that &lt;CODE&gt;date_zone&lt;/CODE&gt; contains the timezone offset in minutes within your timezone calculations.  (It also contains the word "local", so'll have to filter that out, something like:   &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | eval tz_offset_secs=if(date_zone=="local", 0, date_zone*60)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Related question:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://answers.splunk.com/questions/4528/finding-your-local-timezone-with-eval" rel="nofollow"&gt;Finding your local timezone with eval?&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Thu, 07 Oct 2010 20:29:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-localize-date-mday/m-p/65878#M16342</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-10-07T20:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I localize date_mday?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-localize-date-mday/m-p/65879#M16343</link>
      <description>&lt;P&gt;Just to be accurate, if &lt;CODE&gt;date_zone&lt;/CODE&gt; is &lt;CODE&gt;local&lt;/CODE&gt;, then the offset you use should be the offset of the indexer's local time zone. This would only be zero if the indexer was running on UTC/GMT, but is fixed and known for any given indexer.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Oct 2010 22:08:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-localize-date-mday/m-p/65879#M16343</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-10-07T22:08:44Z</dc:date>
    </item>
  </channel>
</rss>

