<?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 convert the time picker date into readable date formats? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-the-time-picker-date-into-readable-date-formats/m-p/149842#M41940</link>
    <description>&lt;P&gt;Hey. &lt;BR /&gt;
I tried that but got the error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in 'eval' command: The operator at '1438056000 "' and '" 1438660800 "'"' is invalid
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Managed to play around with SQL and got it working, however it didn't work for the presets e.g. last 7 days etc. It works well only when a user selects Date Range and chooses the the between dates.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| dbquery AdWordsROI "SELECT * FROM account_performance  WHERE`Day` between from_unixtime($time_range1.earliest$,'%y-%m-%d')and from_unixtime($time_range1.latest$,'%y-%m-%d')"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I receive this error when I select Last 7 Days&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;command="dbquery", A database error occurred: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@h,'%y-%m-%d')and from_unixtime(now,'%y-%m-%d') group by ClientName' at line 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;basically the earliest and latest time in this case isn't epoch time. What do I need to do?&lt;/P&gt;

&lt;P&gt;from_unixtime is an SQL function that returns normal time from epoch time&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Bob&lt;/P&gt;</description>
    <pubDate>Tue, 04 Aug 2015 09:02:05 GMT</pubDate>
    <dc:creator>BobKimata</dc:creator>
    <dc:date>2015-08-04T09:02:05Z</dc:date>
    <item>
      <title>How do I convert the time picker date into readable date formats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-the-time-picker-date-into-readable-date-formats/m-p/149839#M41937</link>
      <description>&lt;P&gt;Hey guys,&lt;/P&gt;

&lt;P&gt;I have a dashboard table that populates from a SQL search query. The dates in the database are in a normal readable format ie 2015-07-18. I have put a time picker which I want to enable me execute the query when a user selects a date range from the date time picker. I have realized the dates in the time picker are in this format: 1437364800 &lt;/P&gt;

&lt;P&gt;How do I convert this date into a normal time format before it executes in the query? As it is, I don't get any results since I don't have such dates (1437364800 ) in my database. I would like to execute something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;query&amp;gt;
  | dbquery AdWordsROI limit=1000 "select * from account_performance where `Day` between $time_range1.earliest$ and $time_range1.latest$"
&amp;lt;/query&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where time_range1.earliest and time_range1.latest are the dates I need to convert.&lt;/P&gt;

&lt;P&gt;Regards&lt;BR /&gt;
Bob&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 06:50:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-the-time-picker-date-into-readable-date-formats/m-p/149839#M41937</guid>
      <dc:creator>BobKimata</dc:creator>
      <dc:date>2020-09-29T06:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert the time picker date into readable date formats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-the-time-picker-date-into-readable-date-formats/m-p/149840#M41938</link>
      <description>&lt;P&gt;I am trying out this but it doesnt seem to be working either. Where am I going wrong?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;query&amp;gt;
               | dbquery AdWordsROI [ | stats count | head 1  | addinfo | convert timeformat="%Y-%m-%d" ctime(time_range1.earliest), ctime(time_range1.latest)|eval sql_str= "select * from account_performance where Day between '$time_range1.earliest$' and '$time_range1.latest$'"  | return $sql_str 
&amp;lt;/query
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;time_range1 is the token from the time picker. I end up getting the following error:&lt;BR /&gt;
command="dbquery", A database error occurred: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2015 19:12:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-the-time-picker-date-into-readable-date-formats/m-p/149840#M41938</guid>
      <dc:creator>BobKimata</dc:creator>
      <dc:date>2015-07-30T19:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert the time picker date into readable date formats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-the-time-picker-date-into-readable-date-formats/m-p/149841#M41939</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;query&amp;gt;
  | dbquery AdWordsROI [| noop | stats count | convert timeformat="%Y-%m-%d" ctime($time_range1.earliest$), ctime($time_range1.latest$) | eval sql_str= "select * from account_performance where Day between '" . $time_range1.earliest$ . "' and '" . $time_range1.latest$ . "'" | return $sql_str ]
&amp;lt;/query&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Aug 2015 20:28:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-the-time-picker-date-into-readable-date-formats/m-p/149841#M41939</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-01T20:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert the time picker date into readable date formats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-the-time-picker-date-into-readable-date-formats/m-p/149842#M41940</link>
      <description>&lt;P&gt;Hey. &lt;BR /&gt;
I tried that but got the error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in 'eval' command: The operator at '1438056000 "' and '" 1438660800 "'"' is invalid
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Managed to play around with SQL and got it working, however it didn't work for the presets e.g. last 7 days etc. It works well only when a user selects Date Range and chooses the the between dates.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| dbquery AdWordsROI "SELECT * FROM account_performance  WHERE`Day` between from_unixtime($time_range1.earliest$,'%y-%m-%d')and from_unixtime($time_range1.latest$,'%y-%m-%d')"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I receive this error when I select Last 7 Days&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;command="dbquery", A database error occurred: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@h,'%y-%m-%d')and from_unixtime(now,'%y-%m-%d') group by ClientName' at line 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;basically the earliest and latest time in this case isn't epoch time. What do I need to do?&lt;/P&gt;

&lt;P&gt;from_unixtime is an SQL function that returns normal time from epoch time&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Bob&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2015 09:02:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-the-time-picker-date-into-readable-date-formats/m-p/149842#M41940</guid>
      <dc:creator>BobKimata</dc:creator>
      <dc:date>2015-08-04T09:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert the time picker date into readable date formats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-the-time-picker-date-into-readable-date-formats/m-p/149843#M41941</link>
      <description>&lt;P&gt;Maybe this would work, too put the times in double-quotes also, because it is in xml, not in the search bar:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;query&amp;gt;
   | dbquery AdWordsROI [| noop | stats count | convert timeformat="%Y-%m-%d" ctime($time_range1.earliest$), ctime($time_range1.latest$) | eval sql_str= "select * from account_performance where Day between $time_range1.earliest$ and $time_range1.latest$'" | return $sql_str ]
&amp;lt;/query&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Aug 2015 22:58:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-convert-the-time-picker-date-into-readable-date-formats/m-p/149843#M41941</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-06T22:58:05Z</dc:date>
    </item>
  </channel>
</rss>

