Overview
Sometimes it may come in handy to, for example, highlight to a user that there is a year change between two date properties, or perhaps add the year to a notification's contents only when it is not the current year.
Solution
The simple sample below has two date properties configured in an M-Files vault, and we will use property calculator to set a Boolean ("Year changed?") value to true if the year changes.
The date properties are "Dateprop A" and "Dateprop B". To assist in the comparison, we can create 2 text properties to store the year part of the dates, "Dateprop A year" and "Dateprop B year". The latter will always host a date that is greater than the former.
The helper properties can be hidden from regular users.
We can use Property Calculator to capture the year of the dates. Below, you can see the configuration for the "Dateproo A year". The string format defines how we want to format the string. In this case, we just want the year, so "yyyy."
Once "Dateprop B year" has been set up similarly, we can calculate the Boolean value via a comparison between the text fields:
What the above configuration basically means is that the end result of the defined expression will be used to set the value to the Boolean property. If Date A year is smaller than Date B year, the year has changed, so the end result is True (Or, Yes).
