Search code examples
datedynamics-crmdurationcalculated-fieldhardcode

Do calculated fields allow hardcoding dates?


I'm trying to create a calculated field to determine the duration between a date field and another hardcoded date, like this: DIFFINDAYS(test_datefield, "19-Dec-16"), but it won't work.

Is it possible in CRM 2015 or 2016?


Solution

  • You cannot do this directly with a calculated field. It is possible through a layer of indirection:

    If you add a new field to your entity to contain the hardcoded date, you can use a Business Rule to set the value of this field (If HardcodedDate does not contain data Set HardcodedDate to 19-Dec-16).

    Subsequently the two fields can be used in your calculated field: DIFFINDAYS(test_datefield, test_hardcodeddate).