Trying to extract the last item in an array

What I’m trying to do:

I am attempting to list events that occurred more than 4 weeks ago UNLESS an event has taken place since. The events are noted in individual files (they are visits to clients) but clearly I am not interested in the visit six weeks ago when my last visit was yesterday!
The date of the visit is an inline YAML tag that obviously repeats (although naturally not the same date) with each visit; the format is the same across all the client files.

Things I have tried:

I have searched high and low - on Blacksmithgu’s github page, in the fora and generally
on the interweb.
The only apparent “solution” is via the dataviewjs route but I have not found a way of automatically generating today’s date as can be done in vanilla dataview (added to which, I have no idea what I am doing in dataviewjs apart from figuratively prodding with a big stick).

My frustration

  1. I can’t find a dataview solution
  2. I can’t understand the dataviewjs documentation…

Anybody any ideas???

1 Like

Don’t worry, after much head scratching, code copying, frustration, trial and error, I have managed to find something of a solution myself.
Even the examples I tried from here on the forum were of very limited use, but even less so the documentation.

Hopefully I shall not be demanding such an effort again.

Within a function, I parsed the array and returned it to the main script thus:

function whatNot(next) {


      ...&c. &c...		

       var lv = dv.array(next.Visite).last();

	return moment(lv,'YYYY-MM-DD').add(next.Attente).format(dateformat)
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.