<?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>Question Re: Incorrect Result FlexibleSearch Query in CRM and CX Q&amp;A</title>
    <link>https://community.sap.com/t5/crm-and-cx-q-a/incorrect-result-flexiblesearch-query/qaa-p/12110131#M415283</link>
    <description>&lt;P&gt;Please try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; SELECT DISTINCT TO_CHAR({cst:creationtime},'DD/MM/YYYY') FROM {CsTicket AS cst} WHERE {cst:creationtime} BETWEEN TO_DATE('2019/01/08','YYYY/MM/DD') AND TO_DATE('2019/01/09','YYYY/MM/DD')
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The reason why your query failed to fetch correct data is because you compared two strings and not two dates for calculating the range.&lt;/P&gt;
&lt;P&gt;If you need dates in date format instead of string format, you can further change my query to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; SELECT DISTINCT TO_DATE({cst:creationtime},'DD/MM/YYYY') FROM {CsTicket AS cst} WHERE {cst:creationtime} BETWEEN TO_DATE('2019/01/08','YYYY/MM/DD') AND TO_DATE('2019/01/09','YYYY/MM/DD')
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 10 Jan 2019 08:20:55 GMT</pubDate>
    <dc:creator>arvind-kumar_avinash</dc:creator>
    <dc:date>2019-01-10T08:20:55Z</dc:date>
    <item>
      <title>Incorrect Result FlexibleSearch Query</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/incorrect-result-flexiblesearch-query/qaq-p/12110129</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;I'm trying to run the below query but it's not giving me the expected result.&lt;/P&gt;
&lt;P&gt;SELECT DISTINCT to_char({cst:creationtime},'dd/MM/yyyy') FROM {CsTicket AS cst} WHERE to_char({cst:creationtime},'yyyy/MM/dd') BETWEEN '2019/01/08' AND '2019/01/09'&lt;/P&gt;
&lt;P&gt;Can you please help me in finding the issue?&lt;/P&gt;
&lt;P&gt;Hybris:6.2
DB: Oracle
&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 07:51:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/incorrect-result-flexiblesearch-query/qaq-p/12110129</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-01-10T07:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Result FlexibleSearch Query</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/incorrect-result-flexiblesearch-query/qaa-p/12110130#M415282</link>
      <description>&lt;P&gt;The data that it fetches from the DB is not in the date range.
&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 08:17:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/incorrect-result-flexiblesearch-query/qaa-p/12110130#M415282</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-01-10T08:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Result FlexibleSearch Query</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/incorrect-result-flexiblesearch-query/qaa-p/12110131#M415283</link>
      <description>&lt;P&gt;Please try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; SELECT DISTINCT TO_CHAR({cst:creationtime},'DD/MM/YYYY') FROM {CsTicket AS cst} WHERE {cst:creationtime} BETWEEN TO_DATE('2019/01/08','YYYY/MM/DD') AND TO_DATE('2019/01/09','YYYY/MM/DD')
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The reason why your query failed to fetch correct data is because you compared two strings and not two dates for calculating the range.&lt;/P&gt;
&lt;P&gt;If you need dates in date format instead of string format, you can further change my query to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; SELECT DISTINCT TO_DATE({cst:creationtime},'DD/MM/YYYY') FROM {CsTicket AS cst} WHERE {cst:creationtime} BETWEEN TO_DATE('2019/01/08','YYYY/MM/DD') AND TO_DATE('2019/01/09','YYYY/MM/DD')
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Jan 2019 08:20:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/incorrect-result-flexiblesearch-query/qaa-p/12110131#M415283</guid>
      <dc:creator>arvind-kumar_avinash</dc:creator>
      <dc:date>2019-01-10T08:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Result FlexibleSearch Query</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/incorrect-result-flexiblesearch-query/qaa-p/12110132#M415284</link>
      <description>&lt;P&gt;Hi Thanks for the reply. I actually figured it out now. &lt;/P&gt;
&lt;P&gt;Another question, when I convert this to FlexibleSearchQuery where the first date is the start date and the second date is end date, Do I need to keep them in quotes?&lt;/P&gt;
&lt;P&gt;BETWEEN to_date('?startDate','dd/MM/yyyy') AND to_date('?endDate','dd/MM/yyyy')&lt;/P&gt;
&lt;P&gt;or &lt;/P&gt;
&lt;P&gt;BETWEEN to_date(?startDate,'dd/MM/yyyy') AND to_date(?endDate,'dd/MM/yyyy') will work fine?
&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 09:01:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/incorrect-result-flexiblesearch-query/qaa-p/12110132#M415284</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-01-10T09:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Result FlexibleSearch Query</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/incorrect-result-flexiblesearch-query/qaa-p/12110133#M415285</link>
      <description>&lt;P&gt;You are most welcome. &lt;/P&gt;
&lt;P&gt;I suggest using the whole query as a string e.g. &lt;A href="https://help.hybris.com/1811/hcd/8bc399c186691014b8fce25e96614547.html#topic_owf_ltp_g5"&gt;https://help.hybris.com/1811/hcd/8bc399c186691014b8fce25e96614547.html#topic_owf_ltp_g5&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 09:18:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/incorrect-result-flexiblesearch-query/qaa-p/12110133#M415285</guid>
      <dc:creator>arvind-kumar_avinash</dc:creator>
      <dc:date>2019-01-10T09:18:28Z</dc:date>
    </item>
  </channel>
</rss>

