HI- We are working on an application where a user reserves inventory for certain

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

Parents
  • 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
Reply
  • 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
Children
No Data