Hi all,
I want to calculate a date fragment “Year” that’s a year only (type “YYYY”). I want to set “Year” to the year of the start date of my entity. So I defined my computation simply as:
[StartDate]
I get no errors in the SME and the computation works fine (e.g. I will see “2025” being input into “Year” when I enter a start date of “08/01/2025”) but when I hit save, I get an error.
What am I doing wrong?
Best,
Lea
Task_DM.json (5.8 KB)
Task_FM.json (4.0 KB)
Hi @lea-clear-clover
As we mentioned in a recent Monthly Modeling Highlights, " Dates: Starts, Ends, Gaps and Overlaps", Date Fragments are assumed to be the start of that period. As a result the Date Fragment, 2025, evaluates to the Date,2025-01-01.
Rewriting the computation to
Date("01","01",YearFromDate(StartDate))
resolved the issue for me.
Alternatively, you can just write this into a Number Field using
YearFromDate(StartDate)
FYI, although the Computation Rule is not marked as invalid the error text was also shown in the Ad Hoc test.
Thanks, that worked! Maybe I need to watch that MHH again because date fragments seem very untuitive to me still.
Btw, it would be nice if this was mentioned in the documentation as well (not sure if you’re the right person to tell this).
I’ve passed the documentation request on to the Kernel Team 
A snippet was added to the documentation in 2024.06-ext4 relating to how Computation Rules also lead to Validation, Computation Rules as Validation Rules.
One of the examples talks about computing a date fragment from a more precise date or date fragment which is exactly your use-case. Nevertheless, we still plan to improve this section of the documentation to better describe the options that you have.