Using date special functions with datafields

Does this function work with a datafield: @year-of(#contract^date)?

I receive an error-notification because the datafield is undefined, but it doesn’t appear on my datafields page, so I can’t assign a value. How can I fix this?

Thanks in advance!

With very few exceptions, all special @functions work with both hard-coded values (such as "alpha"or 351) and datafields.

What you have to do here:

  • Either include an exclamation mark in the datafield (so @year-of(#contract^!date)), so that the value of that datafield will not be attempted to be used unless a value is assigned to it. Read more about these exclamation marks in a previous post: No yellow box is shown for a datafield

  • Or enclose the special function in a condition where you first check whether a value is assigned to the datafield, e.g.{#contract^date: ... @year-of(#contract^date) | else: !! no value assigned !!}

Also, maybe good to point out that the standard setting of the datafields page (“data dashboard”) is to only show values that are effectively used in calculations. As soon as you hit an error (in your case because you are trying to extract the year from a missing value), the software stops evaluating that expression, so it will be not be “used”, and will not show up in the datafields page.

However, there is a setting in the datafields page

image

that is exactly what you are looking for. If checked, it will show all datafields, regardless of whether or not those datafields were effectively used in calculations. (Under the hood, the way the list of datafields is compiled in both scenarios, is completely different.) So even in case of errors, your datafield should show up, ready to be assigned a value to it.