<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Overlapping Range Check</title><link>https://community.appian.com/discussions/f/general/18106/overlapping-range-check</link><description>Hi, 
 There are two date fields in database &amp;#39;startDate&amp;#39; and &amp;#39;endDate&amp;#39; for every record. I want to check overlapping conditions while user try to insert new set of date range for a new record. For eg. if we had &amp;#39;startDate&amp;#39; and &amp;#39;endDate&amp;#39; as &amp;#39;20 Dec 2019</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Overlapping Range Check</title><link>https://community.appian.com/thread/71222?ContentTypeID=1</link><pubDate>Thu, 02 Jan 2020 19:20:07 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e8b0b88b-34f7-481d-b683-0b2e8ce3d7ac</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;Ah good call - you&amp;#39;re right I missed one &lt;span class="emoticon" data-url="https://community.appian.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Overlapping Range Check</title><link>https://community.appian.com/thread/71221?ContentTypeID=1</link><pubDate>Thu, 02 Jan 2020 19:08:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:77095da8-1ee3-4915-9efe-dae648a4f63a</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;I believe there is one additional scenario to consider, when an existing range starts after the start date and ends prior to the end date (provided dates surrounding completely).&amp;nbsp; All can be covered by&amp;nbsp;reducing to one scenario:&lt;/p&gt;
&lt;p&gt;1.&amp;nbsp;An existing range starts &amp;lt;= to the end date you provided and ends &amp;gt;= the start date you provided&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!queryEntity(
  entity: cons!&amp;lt;YOUR ENTITY HERE&amp;gt;,
  query: a!query(
    pagingInfo: a!pagingInfo(
      startIndex: 1,
      batchSize: -1
    ),
    logicalExpression: a!queryLogicalExpression(
      operator: &amp;quot;AND&amp;quot;,
      filters: {
        a!queryFilter(
          field: &amp;quot;startDate&amp;quot;,
          operator: &amp;quot;&amp;lt;=&amp;quot;,
          value: ri!newEndDate
        ),
        a!queryFilter(
          field: &amp;quot;endDate&amp;quot;,
          operator: &amp;quot;&amp;gt;=&amp;quot;,
          value: ri!newStartDate
        )
      }
    )
  ),
  fetchTotalCount: false
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Overlapping Range Check</title><link>https://community.appian.com/thread/71215?ContentTypeID=1</link><pubDate>Thu, 02 Jan 2020 14:36:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c6797c1f-9cb2-4720-8a2b-cd8e7a72eb7a</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;I think the easiest way to do this is to query the database and use a logical expression to check for 2 possible conditions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;An&amp;nbsp;existing range starts before the start date you provided and ends after the start date you provided&lt;/li&gt;
&lt;li&gt;An existing range starts before the end date you provided and ends after the end date you provided&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If either of those conditions are true, then the ranges overlap. Here&amp;#39;s a sample code to perform the query:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!queryEntity(
  entity: cons!&amp;lt;YOUR ENTITY HERE&amp;gt;,
  query: a!query(
    pagingInfo: a!pagingInfo(
      startIndex: 1,
      batchSize: -1
    ),
    logicalExpression: a!queryLogicalExpression(
      operator: &amp;quot;OR&amp;quot;,
      logicalExpressions: {
        a!queryLogicalExpression(
          operator: &amp;quot;AND&amp;quot;,
          filters: {
            a!queryFilter(
              field: &amp;quot;startDate&amp;quot;,
              operator: &amp;quot;&amp;lt;&amp;quot;,
              value: ri!newStartDate
            ),
            a!queryFilter(
              field: &amp;quot;endDate&amp;quot;,
              operator: &amp;quot;&amp;gt;&amp;quot;,
              value: ri!newStartDate
            )
          }
        ),
        a!queryLogicalExpression(
          operator: &amp;quot;AND&amp;quot;,
          filters: {
            a!queryFilter(
              field: &amp;quot;startDate&amp;quot;,
              operator: &amp;quot;&amp;lt;&amp;quot;,
              value: ri!newEndDate
            ),
            a!queryFilter(
              field: &amp;quot;endDate&amp;quot;,
              operator: &amp;quot;&amp;gt;&amp;quot;,
              value: ri!newEndDate
            )
          }
        )
      }
    )
  ),
  fetchTotalCount: false
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>