How Check if a date is in next 14 days?

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. 

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Hi,

    How to check if a list of dates has any date <= today() + 14? The above condition works for single date. But without using foreach how to find count of all dates that are <= today()+14 in a list of dates? Sample code being used is below

    with(
    local!events: rule!GetAllEventsExpressionRule(),
    local!statusList: rule!GetStatusList().result.body,
    local!etbc_array: {},
    a!forEach(
    items: index(
    index(
    local!events.data,
    "RequestedDate",
    {}
    ),
    wherecontains(
    displayvalue(
    "Pending",
    index(
    local!statusList,
    "Status",
    {}
    ),
    index(
    local!statusList,
    "Id",
    {}
    ),
    {}
    ),
    index(
    local!events.data,
    "Status",
    {}
    )
    ),
    {}
    ),
    expression: if(
    todate(
    todatetime(
    fv!item
    )
    ) > todate(
    caladddays(
    today(),
    14
    )
    ),
    if(count(fv!item) > 0, fv!item, null),
    {}
    )
    )
    )

    Tried to use foreach which works fine in positive scenario, but in negative scenario it's returning 0 in list of variants due to which when i try length(dates from list of dates that are <= 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.

    List of Variant: 2 items
    List of Variant: 0 items
    List of Variant: 0 items