<?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 DB Connect Convert Epoch to DateTime in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Convert-Epoch-to-DateTime/m-p/127865#M184382</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have an MySQL database and I am trying to index some data from it. I can connect with no problems and I can index the data if I use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;select * from &amp;lt;table&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, the date field is stored as an INT.&lt;/P&gt;

&lt;P&gt;I have tried the following code but it doesn't work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;select d.productid, d.amount, o.orderid, cast(o.`date` as datetime)
from xcart_orders o, xcart_order_details d  
where o.orderid = d.orderid {{ and o.$rising_column$ &amp;gt; ? }}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How would I convert from Unix Epoch time store as an INT to something that Splunk will recognise as DATETIME? Normally, in SQL I would use &lt;CODE&gt;DATEADD();&lt;/CODE&gt; but Splunk doesn't seem to recognise that command.&lt;/P&gt;</description>
    <pubDate>Thu, 10 Apr 2014 23:11:29 GMT</pubDate>
    <dc:creator>justinfranks</dc:creator>
    <dc:date>2014-04-10T23:11:29Z</dc:date>
    <item>
      <title>DB Connect Convert Epoch to DateTime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Convert-Epoch-to-DateTime/m-p/127865#M184382</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have an MySQL database and I am trying to index some data from it. I can connect with no problems and I can index the data if I use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;select * from &amp;lt;table&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, the date field is stored as an INT.&lt;/P&gt;

&lt;P&gt;I have tried the following code but it doesn't work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;select d.productid, d.amount, o.orderid, cast(o.`date` as datetime)
from xcart_orders o, xcart_order_details d  
where o.orderid = d.orderid {{ and o.$rising_column$ &amp;gt; ? }}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How would I convert from Unix Epoch time store as an INT to something that Splunk will recognise as DATETIME? Normally, in SQL I would use &lt;CODE&gt;DATEADD();&lt;/CODE&gt; but Splunk doesn't seem to recognise that command.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2014 23:11:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Convert-Epoch-to-DateTime/m-p/127865#M184382</guid>
      <dc:creator>justinfranks</dc:creator>
      <dc:date>2014-04-10T23:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: DB Connect Convert Epoch to DateTime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Convert-Epoch-to-DateTime/m-p/127866#M184383</link>
      <description>&lt;P&gt;When you say "it doesn't work", what error are you seeing?&lt;/P&gt;

&lt;P&gt;Have you looked at this answer? &lt;A href="http://answers.splunk.com/answers/126547/db-connect-epoch-timestamp"&gt;http://answers.splunk.com/answers/126547/db-connect-epoch-timestamp&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2014 11:59:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Convert-Epoch-to-DateTime/m-p/127866#M184383</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2014-04-11T11:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: DB Connect Convert Epoch to DateTime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Convert-Epoch-to-DateTime/m-p/127867#M184384</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;When running that exact command without the rising column bit, i get:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;productid   amount  orderid cast(o.`date` as date time)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;with no data in the cast column. &lt;/P&gt;

&lt;P&gt;Unfortunately, Splunk is not recognising the date when it gets indexed, so the "_time" field is when the data was indexed. This is why I am trying to convert it before it is indexed.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Apr 2014 23:41:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Convert-Epoch-to-DateTime/m-p/127867#M184384</guid>
      <dc:creator>justinfranks</dc:creator>
      <dc:date>2014-04-13T23:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: DB Connect Convert Epoch to DateTime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Convert-Epoch-to-DateTime/m-p/127868#M184385</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;If your rising column field is your date field that you are mentioning then its not possible.&lt;/P&gt;

&lt;P&gt;If its not then you can use&lt;/P&gt;

&lt;P&gt;select to_char(date_attribute,'YYYY-MM-DD HH24:MI:SS') date_attribute,id from table_name {{WHERE $rising_column$ &amp;gt; ?}}&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:23:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Convert-Epoch-to-DateTime/m-p/127868#M184385</guid>
      <dc:creator>harshavrath</dc:creator>
      <dc:date>2020-09-28T16:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: DB Connect Convert Epoch to DateTime</title>
      <link>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Convert-Epoch-to-DateTime/m-p/127869#M184386</link>
      <description>&lt;P&gt;I am seeing this too. You can use the FROM_UNIXTIME(o.date) to get the UTC readable version of the int. If you want to convert that to your timezone, I am not sure how to do that when just pulling the data in with MySQL since DB Connnect 2, the one I am using will not allow a query with CONVERT_TZ to actually be used and return results (this is true at the time I am typing this an may be corrected later). You can however do that after the fact in the Splunk queries.&lt;/P&gt;

&lt;P&gt;You probably have already figured this out but I thought it may be helpful for anyone else seeing this.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:17:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/DB-Connect-Convert-Epoch-to-DateTime/m-p/127869#M184386</guid>
      <dc:creator>jsilverbears</dc:creator>
      <dc:date>2020-09-29T09:17:36Z</dc:date>
    </item>
  </channel>
</rss>

