One strength of Notes development is the way it gives us so many approaches to achieving the same goal. Lots of different languages and methods to choose from. The formula language for one is great. It gives us simple ways of achieving seemingly complicated ends.
On the flipside it's easy to forget all the different methods involved, as there are so many of them and you can go for so long without needing any one particular technique. For example, at the moment I'm struggling to remember how to do something which I'm pretty sure is both possible and quite simple. It's just that, with the Formula engine and the tricks that rely on it, there's often a lack of intuition involved and it's more a case of remembering exactly how it's done.
Anyway, at risk of turning this in to my very own forum, I have another brain teaser for you. On a form I want a field called Year, which lets you choose a value anywhere between five years ago and ten years in the future. So, now, it would include 2001, 2002, ... 2005, 2006, 2007 .... 2016. Make sense?
How do I do this in Formula? At first I thought it would be a simple job, but I can't seem to get the function I need. Here's what I came up with and from where I can get no further:
@Explode( @TextToTime( @Text(@Adjust(@Now;-5;0;0;0;0;0)) + " - " + @Text(@Adjust(@Now;10;0;0;0;0;0)) ) )
The result of this is a text list of every single day for a period of fifteen years. All I want are the years. I tried wrapping the whole thing with a @Unique(@Year()) but that didn't work. I'm stuck.
I know I could probably use a @For or @While but that seems like cheating. I like the simple @Function tricks that seem to defy logic, but always give us what we want.