Calculate days passed since event
I would simply like to display how many days have passed since an experiment was performed (a date field in the Experiments app). Any suggestion as to how this calculation would look? I suppose it involves pulling the current date, but I have no clue as to how to achieve this...
Philip, as a part of a logging app for a study, there is a date field simply called "Date of experiment". Following this, I've entered the formula according to my first reply: moment(Date of experiment).fromNow();
(Addition: if you add "true" in the last parentheses -- moment(Date of experiment).fromNow(true); -- the output changes from for instance "7 days ago" to just "7 days")
All this is just to keep track of how much time has elapsed since the experiment!
John, apparently by writing
var now = moment(Date of experiment)
var then = moment(Date of termination)
I know I've seen a way to also customize entirely the output, so that you could for example get something similar to:
and so on.
This is my script as it exists from this thread....
Maybe the documentation over at http://momentjs.com/ is helpful? Also, just to be clear, are you referring to the date field (by placing @ in front of the name)?
Please sign in to leave a comment.