Combining a repeating list with special functions

Hi,

I created a repeating list datafield to insert multiple dates in a table.

In a specific clause, I want to refer to the earliest date in that table. I tried using the “@earliest” special function, but this does not work.

Is there some way to use this special function on a repeating list datafield with multiple dates?

Thanks in advance!

Hi Isha,

The @earliest function is a good match, but unfortunately it indeed only supports two dates.

You can however, use the following:

  1. In your Content Body (assuming #date^dates is the repeating list):

@clj("earliest-of-dates", #dates^dates)

  1. Then add an earliest-of-dates custom function with the following content:

    (defn earliest-date [d1 d2]

    (let [d1 (or (:date d1) d1) ; unbox param
    d2 (or (:date d2) d2)]
    (cond (< (:year d1) (:year d2)) d1
    (> (:year d1) (:year d2)) d2
    (< (:month d1) (:month d2)) d1
    (> (:month d1) (:month d2)) d2
    (< (:day d1) (:day d2)) d1
    (> (:day d1) (:day d2)) d2
    :else d1)))

    (reduce earliest-date $1)

  2. Don’t be too concerned about that funny looking function in the previous step, it is quite advanced programming. Essentially, the content body will invoke the custom function earliest-of-dates, pass it your repeating list, and then get back the earliest of all the dates that happen to be present in that repeating list.

Tip: the “Custom functions” is hidden by default. I just upgraded your rights so that you can see access it; you may have to refresh your browser page.

image

It worked, thanks a lot for the quick and very helpful reply!