Closed dbl-mm closed 5 years ago
Have you tried the Humanizer node instead of the main moment node? I think that should do the job of giving you dates such as "Last Friday".
hm... i thought i could use node-red-contrib-moment to calculate (output) the last friday from the input. so for example i enter today's date 14.08.2019 and get the answer date 09.08.2019 (the date of last friday)
Ah, I see. I'm afraid that you can currently only add/subtract in a very simple way.
I've always had a thought to create another node to the repo that let you do more complex calculations but you are the first person to raise an actual use-case :)
Good news though, this is a fairly common requirement and the easiest thing to do is to add a function node. The following gives some examples of JavaScript code that will do the calculation for you.
https://stackoverflow.com/questions/30322894/how-to-get-timestamp-of-last-friday-using-javascript
Added to the list for a future release.
I will add a calculation node that lets you work out things like "last Friday", "last day of the year" "days until" "Is the date a weekday/weekend/special day" and so on.
The output formats described in the docs (https://momentjs.com/docs/#/get-set/day/) doesn't work with node-red-contrib-moment?
For example:
How do I get the last Friday as an output?