<?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 to convert oracle function in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-convert-oracle-function/m-p/37512#M8394</link>
    <description>&lt;P&gt;I am not sure that there is a useful mapping of these functions from SQL to the Splunk search language. The whole philosophy of data retrieval and results manipulation is different. As &lt;A href="http://splunk-base.splunk.com/users/1410/yannk"&gt;yannK&lt;/A&gt; asked - what are you trying to accomplish? Splunk can probably do the same thing, but it may do it in a very different way.&lt;/P&gt;

&lt;P&gt;You might want to look at this short article: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/SQLtoSplunk"&gt;Splunk for SQL Users&lt;/A&gt; in the Search Reference Manual.&lt;/P&gt;

&lt;P&gt;All of that said, Splunk is very good with date arithmetic. For &lt;CODE&gt;MONTHS_BETWEEN&lt;/CODE&gt;, you could do the calculation in a variety of ways. The easiest would be based on the number of days between the two dates, divided by 31:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval mon_between = (later_time - earlier_time) / (86400 * 31)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but other algorithms are possible. For &lt;CODE&gt;LASTDAY&lt;/CODE&gt;, I would use a lookup table that contains the month, day and year of the last day of the month. (The lookup table could also be incorporated into the &lt;CODE&gt;MONTHS_BETWEEN&lt;/CODE&gt; calculation.)&lt;/P&gt;

&lt;P&gt;If you want to do this sort of thing a lot, you could create a macro to do the calculations. You could even name the macros &lt;CODE&gt;LASTDAY&lt;/CODE&gt; and &lt;CODE&gt;MONTHS_BETWEEN&lt;/CODE&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;The RANK function is a bit harder for Splunk. Sure, it can be done easily enough, but it does not map-reduce well. So it is a simple but ugly problem when you are dealing with big data. For this, we really &lt;EM&gt;do&lt;/EM&gt; need to know what you are trying to do.&lt;/P&gt;

&lt;P&gt;But maybe people with greater SQL or Splunk expertise will have a better answer.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Feb 2013 07:48:03 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2013-02-20T07:48:03Z</dc:date>
    <item>
      <title>how to convert oracle function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-convert-oracle-function/m-p/37510#M8392</link>
      <description>&lt;P&gt;hello .&lt;BR /&gt;
i want to convert oracle function to splunk search. &lt;BR /&gt;
but i don't know this conversion .&lt;/P&gt;

&lt;P&gt;here's oracle function.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;oraacle function   -----------------------------------------------------------------------------------------------&amp;gt;  splunk search&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;LAST_DAY(YYYYMMDD)   -----------------------------------------------------------------------------------------------&amp;gt;???&lt;BR /&gt;&lt;BR /&gt;
MONTHS_BETWEEN(YYYYMMDD1, YYYYMMDD2) -------------------------------------------------------&amp;gt; ???&lt;BR /&gt;&lt;BR /&gt;
RANK() OVER ( PARTITION BY LN_YYMM ORDER BY STD_YYMM DESC )   ----------------------&amp;gt; ???             &lt;/P&gt;

&lt;P&gt;How to convert oracle function to splunk search?&lt;BR /&gt;
please help me. lol&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:21:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-convert-oracle-function/m-p/37510#M8392</guid>
      <dc:creator>rimururu01</dc:creator>
      <dc:date>2020-09-28T13:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert oracle function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-convert-oracle-function/m-p/37511#M8393</link>
      <description>&lt;P&gt;what are supposed to do those functions ?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2013 07:04:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-convert-oracle-function/m-p/37511#M8393</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2013-02-20T07:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert oracle function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-convert-oracle-function/m-p/37512#M8394</link>
      <description>&lt;P&gt;I am not sure that there is a useful mapping of these functions from SQL to the Splunk search language. The whole philosophy of data retrieval and results manipulation is different. As &lt;A href="http://splunk-base.splunk.com/users/1410/yannk"&gt;yannK&lt;/A&gt; asked - what are you trying to accomplish? Splunk can probably do the same thing, but it may do it in a very different way.&lt;/P&gt;

&lt;P&gt;You might want to look at this short article: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/SQLtoSplunk"&gt;Splunk for SQL Users&lt;/A&gt; in the Search Reference Manual.&lt;/P&gt;

&lt;P&gt;All of that said, Splunk is very good with date arithmetic. For &lt;CODE&gt;MONTHS_BETWEEN&lt;/CODE&gt;, you could do the calculation in a variety of ways. The easiest would be based on the number of days between the two dates, divided by 31:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval mon_between = (later_time - earlier_time) / (86400 * 31)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but other algorithms are possible. For &lt;CODE&gt;LASTDAY&lt;/CODE&gt;, I would use a lookup table that contains the month, day and year of the last day of the month. (The lookup table could also be incorporated into the &lt;CODE&gt;MONTHS_BETWEEN&lt;/CODE&gt; calculation.)&lt;/P&gt;

&lt;P&gt;If you want to do this sort of thing a lot, you could create a macro to do the calculations. You could even name the macros &lt;CODE&gt;LASTDAY&lt;/CODE&gt; and &lt;CODE&gt;MONTHS_BETWEEN&lt;/CODE&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;The RANK function is a bit harder for Splunk. Sure, it can be done easily enough, but it does not map-reduce well. So it is a simple but ugly problem when you are dealing with big data. For this, we really &lt;EM&gt;do&lt;/EM&gt; need to know what you are trying to do.&lt;/P&gt;

&lt;P&gt;But maybe people with greater SQL or Splunk expertise will have a better answer.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2013 07:48:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-convert-oracle-function/m-p/37512#M8394</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-02-20T07:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert oracle function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-convert-oracle-function/m-p/37513#M8395</link>
      <description>&lt;P&gt;Another great tool to look at for date fiddling is the eval function relative_time(). For instance, you could implement LASTDAY like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1000 increment=1d | eval last_day = strftime(relative_time(starttime, "+mon@mon-d"), "%F %T") | dedup last_day
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Feb 2013 09:12:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-convert-oracle-function/m-p/37513#M8395</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-02-20T09:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert oracle function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-convert-oracle-function/m-p/37514#M8396</link>
      <description>&lt;P&gt;Martin - brilliant suggestion for LASTDAY. I could not come up with "mon@mon-d"&lt;BR /&gt;
but I knew there had to be a way!&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2013 15:56:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-convert-oracle-function/m-p/37514#M8396</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-02-20T15:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to convert oracle function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-convert-oracle-function/m-p/37515#M8397</link>
      <description>&lt;P&gt;You should buy whoever built the relative time modifiers a beer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;As for your mon_between, I believe with Oracle February 1st and March 1st should have exactly 1.0 months between each other. I gave it a stab like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[months_between(2)]
args = arg1,arg2
definition = (tonumber(strftime($arg1$, "%Y")) - tonumber(strftime($arg2$, "%Y")))*12 + (tonumber(strftime($arg1$, "%m")) - tonumber(strftime($arg2$, "%m"))) + (tonumber(strftime($arg1$, "%d")) - tonumber(strftime($arg2$, "%d")))/31
iseval = 0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Feb 2013 18:07:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-convert-oracle-function/m-p/37515#M8397</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-02-20T18:07:01Z</dc:date>
    </item>
  </channel>
</rss>

