<?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: Splunk DB Connect 1: Using to_char and to_date functions with dbquery results in no results found in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-DB-Connect-1-Using-to-char-and-to-date-functions-with/m-p/247552#M99154</link>
    <description>&lt;P&gt;Let's fix your original search; it will be way easier.  Add a comment with the COMPLETE search for the &lt;CODE&gt;fieldformat&lt;/CODE&gt; method.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Jul 2016 16:39:05 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2016-07-12T16:39:05Z</dc:date>
    <item>
      <title>Splunk DB Connect 1: Using to_char and to_date functions with dbquery results in no results found</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-DB-Connect-1-Using-to-char-and-to-date-functions-with/m-p/247549#M99151</link>
      <description>&lt;P&gt;Hello and thank you in advance for any help .&lt;/P&gt;

&lt;P&gt;I am creating a dashboard for our customer service team, using a dbquery to return the records they require for troubleshooting purposes.&lt;BR /&gt;
I have everything working just fine, however, when I try to format the date fields returned from the query using &lt;STRONG&gt;to_char&lt;/STRONG&gt; or &lt;STRONG&gt;to_date&lt;/STRONG&gt; functions, I get no results found. As an example, here is one the fields I am returning;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;max(I.CREATED_DATE)&lt;/STRONG&gt; if I update it to &lt;STRONG&gt;to_char(max(I.CREATED_DATE), 'MM/DD/YYY')&lt;/STRONG&gt; I go from good results to no results found.&lt;/P&gt;

&lt;P&gt;I'd also like to give the customer service team the option of inputting two dates, so they can filter the data by a specified range. If I add;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;AND sfu.SCHDLD_FLLW_UP_DATE BETWEEN TO_DATE('07/11/2016','MM/DD/YYYY') AND TO_DATE('08/25/2016', 'MM/DD/YYYY')&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;to the query I get no results. Everything works like a charm in TOAD, just seems to be something Splunk doesn't like. I've tried several different options with case but nothing seems to work.&lt;/P&gt;

&lt;P&gt;What am I missing here? Please help and thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:09:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-DB-Connect-1-Using-to-char-and-to-date-functions-with/m-p/247549#M99151</guid>
      <dc:creator>g038123</dc:creator>
      <dc:date>2020-09-29T10:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk DB Connect 1: Using to_char and to_date functions with dbquery results in no results found</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-DB-Connect-1-Using-to-char-and-to-date-functions-with/m-p/247550#M99152</link>
      <description>&lt;P&gt;You are asking an &lt;CODE&gt;SQL&lt;/CODE&gt; question in the wrong place.  The &lt;CODE&gt;Splunk&lt;/CODE&gt; answer is to do the formatting inside of Splunk with your original working search like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | fieldformat CREATED_DATE = strftime(CREATED_DATE, "%m/%d/%Y")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The same thing for the 2 dates, have them pick the dates from a &lt;CODE&gt;timepicker&lt;/CODE&gt; tool which will return a &lt;CODE&gt;time_t&lt;/CODE&gt; (epoch) value which will not need to be converted (or use the same trick above, to convert it in splunk before passing it to SQL).&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2016 20:37:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-DB-Connect-1-Using-to-char-and-to-date-functions-with/m-p/247550#M99152</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-07-08T20:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk DB Connect 1: Using to_char and to_date functions with dbquery results in no results found</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-DB-Connect-1-Using-to-char-and-to-date-functions-with/m-p/247551#M99153</link>
      <description>&lt;P&gt;I did initially try to use the  fieldformat command, however it doesn't seem to be working. I don't get any results for that field when adding the command to my search. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | fieldformat CREATED_DATE = strftime(CREATED_DATE, "%m/%d/%Y")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That's why, after reading a few other posts, I attempted to use the SQL functions to format the dates but ran into trouble there as well. &lt;BR /&gt;
Sorry, I'm pretty new to Splunk so if I'm missing the obvious, I apologize.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 13:45:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-DB-Connect-1-Using-to-char-and-to-date-functions-with/m-p/247551#M99153</guid>
      <dc:creator>g038123</dc:creator>
      <dc:date>2016-07-12T13:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk DB Connect 1: Using to_char and to_date functions with dbquery results in no results found</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-DB-Connect-1-Using-to-char-and-to-date-functions-with/m-p/247552#M99154</link>
      <description>&lt;P&gt;Let's fix your original search; it will be way easier.  Add a comment with the COMPLETE search for the &lt;CODE&gt;fieldformat&lt;/CODE&gt; method.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2016 16:39:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-DB-Connect-1-Using-to-char-and-to-date-functions-with/m-p/247552#M99154</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-07-12T16:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk DB Connect 1: Using to_char and to_date functions with dbquery results in no results found</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-DB-Connect-1-Using-to-char-and-to-date-functions-with/m-p/247553#M99155</link>
      <description>&lt;P&gt;Ok, here is the complete search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| dbxquery query="SELECT P.PARTY_ID,P.LAST_NAME || ',' || P.FIRST_NAME,PMST.PATIENT_MNTRNG_STATUS_DESC,cy.ctry,M.BASE_MODEL_NBR || '_' || D.SERIAL_NBR, min(SFU.SCHDLD_FLLW_UP_DATE),max(I.CREATED_DATE)
    FROM   PATIENT_MNTRNG_STATUS pms,PATIENT_MNTRNG_STATUS_TYPE pmst,
           device d,assgnd_device ad,
           patient_clinic pc,ctry cy,
           contact c,REVIEW_SUMMARY rs,
           PATIENT_FLLWNG pf,MODEL m,
           PARTY p,EXT_ACCT ea,APM.INTRGTN i,
           SCHDLD_FLLW_UP sfu
   WHERE   pms.PATIENT_MNTRNG_STATUS_TYPE_ID =pmst.PATIENT_MNTRNG_STATUS_TYPE_ID
           AND PMS.PARTY_ID = PC.PATIENT_PARTY_ID
           AND PC.PATIENT_PARTY_ID = AD.PARTY_ID
           AND AD.PARTY_ID = P.PARTY_ID
           AND AD.PARTY_ID = I.PARTY_ID(+)
           AND PC.CLINIC_PARTY_ID = C.PARTY_ID
           AND C.PARTY_ID = EA.PARTY_ID
           AND PC.PATIENT_CLINIC_ID = RS.PATIENT_CLINIC_ID
           AND RS.PATIENT_FLLWNG_TYPE_CD = 'DVCE'
           AND RS.REVIEW_SUMMARY_ID = PF.REVIEW_SUMMARY_ID
           AND C.CTRY_ID = CY.CTRY_ID
           AND D.MODEL_TYPE_CD = 'PG'
           AND D.MODEL_ID = M.MODEL_ID
           AND D.USED_FLAG = 'Y'
           AND AD.DEVICE_ID = D.DEVICE_ID
           AND EA.EXT_ACCT = 'SAP_ID'
           AND EA.EXT_ACCT_TYPE_CD = 'SAP'
           AND SFU.PATIENT_FLLWNG_ID = PF.PATIENT_FLLWNG_ID
           AND SFU.INTRGTN_ID is NULL
           AND SFU.CANCELLED_DATE is NULL
           AND AD.END_DATE IS NULL
Group by P.PARTY_ID,P.LAST_NAME,P.FIRST_NAME,PMST.PATIENT_MNTRNG_STATUS_DESC,cy.ctry,M.BASE_MODEL_NBR,D.SERIAL_NBR" connection=US_NXT_STDBY shortnames=t
| stats list("P LAST_NAME||','||P   FIRST_NAME") as NAME
        list(PATIENT_MNTRNG_STATUS_DESC) as Monitoring_Status
        list("M BASE_MODEL_NBR||'_'||D  SERIAL_NBR") as PG
        list(MIN(SFU    SCHDLD_FLLW_UP_DATE)) as Next_Remote_Follow_Up
        list(MAX(I  CREATED_DATE)) AS CREATED_DATE by PARTY_ID
| sort NAME
|  fieldformat CREATED_DATE = strftime(CREATED_DATE, "%m/%d/%Y")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is the returned format for the CREATED_DATE without the fieldformat:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;**2016-07-11 08:53:44.588**
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When adding:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fieldformat CREATED_DATE = strftime(CREATED_DATE, "%m/%d/%Y")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then I get no results in the CREATED_DATE field.&lt;/P&gt;

&lt;P&gt;Let me know if you need anything else and thank you for the help!!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2016 20:54:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-DB-Connect-1-Using-to-char-and-to-date-functions-with/m-p/247553#M99155</guid>
      <dc:creator>g038123</dc:creator>
      <dc:date>2016-07-14T20:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk DB Connect 1: Using to_char and to_date functions with dbquery results in no results found</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-DB-Connect-1-Using-to-char-and-to-date-functions-with/m-p/247554#M99156</link>
      <description>&lt;P&gt;It appears that &lt;CODE&gt;CREATED_DATE&lt;/CODE&gt; is not a &lt;CODE&gt;time_t&lt;/CODE&gt; (epoch) but a string.  Therefore, instead of this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fieldformat CREATED_DATE = strftime(CREATED_DATE, "%m/%d/%Y")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Use this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fieldformat CREATED_DATE = strftime(strptime(CREATED_DATE, "%Y-%m-%d %H:%M:%S.%3N"), "%m/%d/%Y")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Jul 2016 22:25:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-DB-Connect-1-Using-to-char-and-to-date-functions-with/m-p/247554#M99156</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-07-15T22:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk DB Connect 1: Using to_char and to_date functions with dbquery results in no results found</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-DB-Connect-1-Using-to-char-and-to-date-functions-with/m-p/247555#M99157</link>
      <description>&lt;P&gt;Yes! Perfect&lt;BR /&gt;
Thank you for the help. Crazy how I over thought it.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 16:14:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-DB-Connect-1-Using-to-char-and-to-date-functions-with/m-p/247555#M99157</guid>
      <dc:creator>g038123</dc:creator>
      <dc:date>2016-07-18T16:14:15Z</dc:date>
    </item>
  </channel>
</rss>

