parsing a date array

I have an array that contains a number of dates. I want to provide a month i.e 11 and have Appian return the date for the next month.

i.e

List of Timestamp: 12 items
24/04/2018 12:00 BST 
29/05/2018 12:00 BST
26/06/2018 12:00 BST
24/07/2018 12:00 BST
21/08/2018 12:00 BST
18/09/2018 12:00 BST
16/10/2018 12:00 BST
13/11/2018 12:00 GMT
11/12/2018 12:00 GMT
29/01/2019 12:00 GMT
26/02/2019 12:00 GMT
26/03/2019 12:00 GMT

 

Provide '10' and have as a return 

13/11/2018 12:00 GMT

 

I've tried using wherecontains to get the index but it only matches if i provide a full string (16/10/2018 12:00 BST ), not a subset. 
Any ideas ?

  Discussion posts and replies are publicly visible

Parents
  • You may try the following expression rule -

    Use: itemIndex as a rule input (integer)

    = load(
    local!allDates: {
    "24/04/2018 12:00 BST",
    "29/05/2018 12:00 BST",
    "26/06/2018 12:00 BST",
    "24/07/2018 12:00 BST",
    "21/08/2018 12:00 BST",
    "18/09/2018 12:00 BST",
    "16/10/2018 12:00 BST",
    "13/11/2018 12:00 GMT",
    "11/12/2018 12:00 GMT",
    "29/01/2019 12:00 GMT",
    "26/02/2019 12:00 GMT",
    "26/03/2019 12:00 GMT"
    },
    local!appianDates: a!forEach(
    items: local!allDates,
    expression: todate(
    split(
    fv!item,
    "/"
    )[2] & "/" & split(
    fv!item,
    "/"
    )[2] & "/" & split(
    fv!item,
    "/"
    )[3]
    )
    ),
    local!searchIndex: if(
    or(
    rule!APN_isBlank(
    ri!itemIndex
    ),
    ri!itemIndex <= 0,
    ri!itemIndex >= max(
    month(
    local!appianDates
    )
    )
    ),
    1,
    wherecontains(
    ri!itemIndex + 1,
    month(
    local!appianDates
    )
    )
    ),
    index(
    local!allDates,
    local!searchIndex,
    null
    )
    )
Reply
  • You may try the following expression rule -

    Use: itemIndex as a rule input (integer)

    = load(
    local!allDates: {
    "24/04/2018 12:00 BST",
    "29/05/2018 12:00 BST",
    "26/06/2018 12:00 BST",
    "24/07/2018 12:00 BST",
    "21/08/2018 12:00 BST",
    "18/09/2018 12:00 BST",
    "16/10/2018 12:00 BST",
    "13/11/2018 12:00 GMT",
    "11/12/2018 12:00 GMT",
    "29/01/2019 12:00 GMT",
    "26/02/2019 12:00 GMT",
    "26/03/2019 12:00 GMT"
    },
    local!appianDates: a!forEach(
    items: local!allDates,
    expression: todate(
    split(
    fv!item,
    "/"
    )[2] & "/" & split(
    fv!item,
    "/"
    )[2] & "/" & split(
    fv!item,
    "/"
    )[3]
    )
    ),
    local!searchIndex: if(
    or(
    rule!APN_isBlank(
    ri!itemIndex
    ),
    ri!itemIndex <= 0,
    ri!itemIndex >= max(
    month(
    local!appianDates
    )
    )
    ),
    1,
    wherecontains(
    ri!itemIndex + 1,
    month(
    local!appianDates
    )
    )
    ),
    index(
    local!allDates,
    local!searchIndex,
    null
    )
    )
Children
No Data