<?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 Is there a numeric alternative to date_month? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-numeric-alternative-to-date-month/m-p/73599#M15083</link>
    <description>&lt;P&gt;I'm trying to use a lookup table to get the # of days in the current month (I was told at .conf2012 that is the only way to do it). If there is an operator to return this (similar to date_mday) that would be fantastic, but if not....&lt;/P&gt;

&lt;P&gt;I was told that the date_month field returned a numeric value for the month (i.e. September = 9) but it does not, it returns a string like "september". &lt;/P&gt;

&lt;P&gt;Is there a numeric alternative to this operator where it would return 09 or 9?&lt;/P&gt;</description>
    <pubDate>Thu, 27 Sep 2012 20:18:26 GMT</pubDate>
    <dc:creator>atornes</dc:creator>
    <dc:date>2012-09-27T20:18:26Z</dc:date>
    <item>
      <title>Is there a numeric alternative to date_month?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-numeric-alternative-to-date-month/m-p/73599#M15083</link>
      <description>&lt;P&gt;I'm trying to use a lookup table to get the # of days in the current month (I was told at .conf2012 that is the only way to do it). If there is an operator to return this (similar to date_mday) that would be fantastic, but if not....&lt;/P&gt;

&lt;P&gt;I was told that the date_month field returned a numeric value for the month (i.e. September = 9) but it does not, it returns a string like "september". &lt;/P&gt;

&lt;P&gt;Is there a numeric alternative to this operator where it would return 09 or 9?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2012 20:18:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-numeric-alternative-to-date-month/m-p/73599#M15083</guid>
      <dc:creator>atornes</dc:creator>
      <dc:date>2012-09-27T20:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a numeric alternative to date_month?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-numeric-alternative-to-date-month/m-p/73600#M15084</link>
      <description>&lt;P&gt;yes, use a convertion of _time field.&lt;/P&gt;

&lt;PRE&gt;
mysearch |  convert timeformat="%m" ctime(_time) AS date_month_numeric  | table _time date_month date_month_numeric
&lt;/PRE&gt;

&lt;P&gt;see &lt;A href="http://docs.splunk.com/Documentation/Splunk/4.3.4/SearchReference/convert"&gt;http://docs.splunk.com/Documentation/Splunk/4.3.4/SearchReference/convert&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2012 20:43:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-numeric-alternative-to-date-month/m-p/73600#M15084</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2012-09-27T20:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a numeric alternative to date_month?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-numeric-alternative-to-date-month/m-p/73601#M15085</link>
      <description>&lt;P&gt;It would be better to use&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval month=strftime(_time,"%m")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;even if date_month exists&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2012 20:44:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-numeric-alternative-to-date-month/m-p/73601#M15085</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-09-27T20:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a numeric alternative to date_month?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-numeric-alternative-to-date-month/m-p/73602#M15086</link>
      <description>&lt;P&gt;correct. it is a bad idea to use the date_* fields because:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;they may not exist on all events, depending how the timestamp was extracted&lt;/LI&gt;
&lt;LI&gt;they are &lt;EM&gt;not&lt;/EM&gt; normalized for time zone or DST, but simply have whatever value was represented in the raw event&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;therefore, as lguinn says, it's a lot better to derive it from &lt;CODE&gt;_time&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;but all that said, it's possible to make a lookup table to map from the english name ("september") to the number of days if you really insisted on using date_month (or used &lt;CODE&gt;month_text=strftime(_time,"%b")&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:31:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-numeric-alternative-to-date-month/m-p/73602#M15086</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2020-09-28T12:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a numeric alternative to date_month?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-numeric-alternative-to-date-month/m-p/73603#M15087</link>
      <description>&lt;P&gt;in general, if an &lt;CODE&gt;eval&lt;/CODE&gt; function exists, it is preferred over a standalone search command, eg., &lt;CODE&gt;strftime()&lt;/CODE&gt; or &lt;CODE&gt;strptime()&lt;/CODE&gt; is slightly better than &lt;CODE&gt;convert&lt;/CODE&gt;, &lt;CODE&gt;case()&lt;/CODE&gt; is better than &lt;CODE&gt;rangemap&lt;/CODE&gt; etc.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2012 21:37:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-numeric-alternative-to-date-month/m-p/73603#M15087</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-09-27T21:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a numeric alternative to date_month?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-numeric-alternative-to-date-month/m-p/73604#M15088</link>
      <description>&lt;P&gt;btw, a lookup is not the only way. you can use a &lt;CODE&gt;case()&lt;/CODE&gt; function in the &lt;CODE&gt;eval&lt;/CODE&gt; search command, and while it's a long expression, you can make that expression into a macro.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2012 21:40:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-numeric-alternative-to-date-month/m-p/73604#M15088</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-09-27T21:40:28Z</dc:date>
    </item>
  </channel>
</rss>

