Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
5 replies
Subscribers
8 subscribers
Views
1710 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
HI- We are working on an application where a user reserves inventory for certain
rachealv537
over 10 years ago
HI- We are working on an application where a user reserves inventory for certain events. The events can be over multiple dates. So, the inventory has to be reserved for each day of the event.
Our form has a begin date and an end date. I would like to retrieve the actual dates between and including the beginning date and the end date. The next step is to reserve the inventory for all of these dates. I do not want the user to have to enter every date individually.
Is there a rule or function that already exists to accomplish this? If not, any advice on the best way to accomplish this? Thanks....
OriginalPostID-128100
OriginalPostID-128100
Discussion posts and replies are publicly visible
0
abhi.jana
Appian Employee
over 10 years ago
enumerate(abs(ri!startDate-ri!endDate)+1)+ri!startDate
Returns all dates between and including start and end dates
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Robert Shankin
Appian Employee
over 10 years ago
Hi Racheal -
You can get your list of dates using the following pair of rules:
(rule 1)
rule!test_addDay(firstDay,daysToAdd)
inputs: firstDay, date; daysToAdd, Number (Integer)
definition:
=with(
ri!firstDay+ri!daysToAdd
)
(rule 2)
rule!test_getDatesInclusive(start, end)
inputs: start, date; end, date
definition:
=with(
local!end: ri!end+1,
local!termArray: enumerate(local!end-ri!start),
local!dateArray: repeat(length(termArray),ri!start),
apply(
rule!test_addDay,
merge(
local!dateArray,
local!termArray
)
)
)
usage:
rule!test_getDatesInclusive(11/1/2014, 11/5/2014)
returns:
test_getDatesInclusive: 11/1/2014, 11/2/2014, 11/3/2014, 11/4/2014, 11/5/2014
I hope that helps.
Thanks,
Rob
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike James
Certified Lead Developer
over 10 years ago
Hi - I created an expression rule to add days to your start date.
rule!startDatePlusDay" =ri!startdate+ri!day
then a second expression to iterate over the first one for the number of days needed.
rule!createDateArray =apply(rule!startDatePlusDay,enumerate(tointeger(ri!enddate-ri!startdate)+1),ri!startdate)
with input start of "11/42014" and end date of "11/10/2014" the output is:
{11/4/2014, 11/5/2014, 11/6/2014, 11/7/2014, 11/8/2014, 11/9/2014, 11/10/2014}
Hope that helps!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
rachealv537
over 10 years ago
Thank you very much for your input mikej and Rob. I will give these a try!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
rachealv537
over 10 years ago
Also thanks Abhimanyu Jana! Actually these all worked.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel