<?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>How Check if a date is in next 14 days?</title><link>https://community.appian.com/discussions/f/data/12846/how-check-if-a-date-is-in-next-14-days</link><description>How Check if a date is in next 14 days? any recipe please? The functions are not sufficient enough to use after trying different ways.</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How Check if a date is in next 14 days?</title><link>https://community.appian.com/thread/57724?ContentTypeID=1</link><pubDate>Mon, 09 Jul 2018 14:17:12 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c460e8a0-773a-4dd2-a85e-0eef1dbdbf1a</guid><dc:creator>Umesh Patel</dc:creator><description>Hi Anusha,&lt;br /&gt;
&lt;br /&gt;
Its not very clear why you cannot use foreach, but, if you want to fetch all the dates which are &amp;lt; = 14 days from the list of dates, can you try below code:&lt;br /&gt;
&lt;br /&gt;
with(&lt;br /&gt;
  /* If you want index of dates qualified. index can be useful to retrieve related data from complex or custom data type. &lt;br /&gt;
      Use wherecontains function.&lt;br /&gt;
*/&lt;br /&gt;
  local!qulifiedDateIndex: a!forEach(&lt;br /&gt;
    items: ri!dateList,&lt;br /&gt;
    expression: if(&lt;br /&gt;
      fv!item &amp;lt;= (today() + 14),&lt;br /&gt;
      fv!index,&lt;br /&gt;
      null&lt;br /&gt;
    )&lt;br /&gt;
  ),&lt;br /&gt;
  /* If you want dates qualified*/&lt;br /&gt;
  local!qulifiedDates: a!forEach(&lt;br /&gt;
    items: ri!dateList,&lt;br /&gt;
    expression: if(&lt;br /&gt;
      fv!item &amp;lt;= (today() + 14),&lt;br /&gt;
      fv!item,&lt;br /&gt;
      null&lt;br /&gt;
    )&lt;br /&gt;
  ),&lt;br /&gt;
  reject(fn!isnull, local!qulifiedDates)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
Thanks.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How Check if a date is in next 14 days?</title><link>https://community.appian.com/thread/57718?ContentTypeID=1</link><pubDate>Mon, 09 Jul 2018 13:07:45 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:81eec631-f625-4950-b28d-aa9eef3b9e43</guid><dc:creator>anushas0002</dc:creator><description>Hi,&lt;br /&gt;
&lt;br /&gt;
How to check if a list of dates has any date  &amp;lt;=  today() + 14? The above condition works for single date. But without using foreach how to find count of all dates that are &amp;lt;= today()+14 in a list of dates? Sample code being used is below&lt;br /&gt;
&lt;br /&gt;
with(&lt;br /&gt;
  local!events: rule!GetAllEventsExpressionRule(),&lt;br /&gt;
  local!statusList: rule!GetStatusList().result.body,&lt;br /&gt;
  local!etbc_array: {},&lt;br /&gt;
  a!forEach(&lt;br /&gt;
    items: index(&lt;br /&gt;
      index(&lt;br /&gt;
        local!events.data,&lt;br /&gt;
        &amp;quot;RequestedDate&amp;quot;,&lt;br /&gt;
        {}&lt;br /&gt;
      ),&lt;br /&gt;
      wherecontains(&lt;br /&gt;
        displayvalue(&lt;br /&gt;
          &amp;quot;Pending&amp;quot;,&lt;br /&gt;
          index(&lt;br /&gt;
            local!statusList,&lt;br /&gt;
            &amp;quot;Status&amp;quot;,&lt;br /&gt;
            {}&lt;br /&gt;
          ),&lt;br /&gt;
          index(&lt;br /&gt;
            local!statusList,&lt;br /&gt;
            &amp;quot;Id&amp;quot;,&lt;br /&gt;
            {}&lt;br /&gt;
          ),&lt;br /&gt;
          {}&lt;br /&gt;
        ),&lt;br /&gt;
        index(&lt;br /&gt;
          local!events.data,&lt;br /&gt;
          &amp;quot;Status&amp;quot;,&lt;br /&gt;
          {}&lt;br /&gt;
        )&lt;br /&gt;
      ),&lt;br /&gt;
      {}&lt;br /&gt;
    ),&lt;br /&gt;
    expression: if(&lt;br /&gt;
      todate(&lt;br /&gt;
        todatetime(&lt;br /&gt;
          fv!item&lt;br /&gt;
        )&lt;br /&gt;
      ) &amp;gt; todate(&lt;br /&gt;
        caladddays(&lt;br /&gt;
          today(),&lt;br /&gt;
          14&lt;br /&gt;
        )&lt;br /&gt;
      ),&lt;br /&gt;
        if(count(fv!item) &amp;gt; 0, fv!item, null),&lt;br /&gt;
      {}&lt;br /&gt;
    )&lt;br /&gt;
  )&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
Tried to use foreach which works fine in positive scenario, but in negative scenario it&amp;#39;s returning 0 in list of variants due to which when i try length(dates from list of dates that are &amp;lt;= today() + 14) as shown below. which means irrespective of condition check always the foreach count is being returned instead of count of values that passed the condition in a list.&lt;br /&gt;
	&lt;br /&gt;
List of Variant: 2 items&lt;br /&gt;
    List of Variant: 0 items&lt;br /&gt;
    List of Variant: 0 items&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How Check if a date is in next 14 days?</title><link>https://community.appian.com/thread/57690?ContentTypeID=1</link><pubDate>Mon, 09 Jul 2018 06:16:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:54011956-8600-426d-8e57-51d45b22a28a</guid><dc:creator>Shubham Aware</dc:creator><description>Hi Anusha,&lt;br /&gt;
&lt;br /&gt;
Simply add 14 days to today&amp;#39;s date and check with if respective date is greater than or equals to date&lt;br /&gt;
&lt;br /&gt;
today() + 14  &amp;gt;= ri!date_dt&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How Check if a date is in next 14 days?</title><link>https://community.appian.com/thread/57688?ContentTypeID=1</link><pubDate>Mon, 09 Jul 2018 06:12:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f0e18156-d5df-4bda-8c5c-abc550f6d97a</guid><dc:creator>aratim</dc:creator><description>Hi Anusha,&lt;br /&gt;
This might be helpful:&lt;br /&gt;
if(ri!date+14&amp;gt;=ri!date,&amp;quot;True message&amp;quot;,&amp;quot;False Message&amp;quot;)&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How Check if a date is in next 14 days?</title><link>https://community.appian.com/thread/57662?ContentTypeID=1</link><pubDate>Fri, 06 Jul 2018 15:21:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bf644afc-984d-4355-b7dd-52763f67ebd3</guid><dc:creator>anushas0002</dc:creator><description>tried this but not working as expected the comparision and there is no option to debug the code and it isn&amp;#39;t throwing any error either. It isn&amp;#39;t returning expected value based on that condition.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How Check if a date is in next 14 days?</title><link>https://community.appian.com/thread/57661?ContentTypeID=1</link><pubDate>Fri, 06 Jul 2018 14:34:01 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:065dc0e7-80ab-4dd1-a6e2-5f6f895ec2d2</guid><dc:creator>surendrab0001</dc:creator><description>Hi,&lt;br /&gt;
&lt;br /&gt;
I think below code may be helpful&lt;br /&gt;
&lt;br /&gt;
caladddays(now(), 14)&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How Check if a date is in next 14 days?</title><link>https://community.appian.com/thread/57660?ContentTypeID=1</link><pubDate>Fri, 06 Jul 2018 14:17:45 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b25e9fe5-7d75-4d33-aa45-14a4754014e1</guid><dc:creator>anushas0002</dc:creator><description>There is no date comparision function that can handle string type of date too, instead of having to convert to datetime.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How Check if a date is in next 14 days?</title><link>https://community.appian.com/thread/57636?ContentTypeID=1</link><pubDate>Fri, 06 Jul 2018 05:58:45 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:44b8393e-c873-4e28-a6fb-211d4dd02f3c</guid><dc:creator>deviratnamv</dc:creator><description>Hi Anusha,&lt;br /&gt;
Please try below code ....&lt;br /&gt;
&lt;br /&gt;
a!dateField(&lt;br /&gt;
  value: ri!date,&lt;br /&gt;
  saveInto: ri!date,&lt;br /&gt;
  validations: if(ri!date+14&amp;gt;=ri!date,&amp;quot;True message&amp;quot;,&amp;quot;False Message&amp;quot;)&lt;br /&gt;
)&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How Check if a date is in next 14 days?</title><link>https://community.appian.com/thread/57618?ContentTypeID=1</link><pubDate>Thu, 05 Jul 2018 21:21:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8cb5bf3a-b86d-41a0-8f5e-b28d9b810cf3</guid><dc:creator>harrisont606</dc:creator><description>Which functions are not sufficient?&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How Check if a date is in next 14 days?</title><link>https://community.appian.com/thread/57613?ContentTypeID=1</link><pubDate>Thu, 05 Jul 2018 15:53:44 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b5048210-ce7c-4330-9d04-8b92f38b3901</guid><dc:creator>dipaki</dc:creator><description>Hi &lt;a href="/members/anushas0002"&gt;anushas0002&lt;/a&gt; , &lt;br /&gt;
If I get you understood your question correctly, using below expression in &amp;quot;validation&amp;quot; attribute of date field may help&lt;br /&gt;
&lt;br /&gt;
if(today()+14 &amp;gt;= ri!date, null, &amp;quot;Error&amp;quot;)&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>