Calculated attributes: New operators - DATESPAN & DATEDIFF (v.24)

We're excited to let you know that starting from version 24 of Calculated Attributes, we've introduced two highly anticipated operators:


These additions fulfill a long-awaited need – precise and efficient date manipulation.

Let's skip to the point.

Their usage is straightforward:


Simply select the operator, provide the start and end dates to define an interval, and the result will be the duration of the dates or its segment, depending on the chosen operator.

The STARTDATE and ENDDATE parameters are self-explanatory; they define your interval.

They accept values of types Date or DateTime, and their provider could be a constant, an object's attribute, another expression, etc.

The third parameter, INTERVAL, specifies the unit in which you will receive the result. This can be DAYS, MONTHS, YEARS. The default is DAYS.

You can opt for shorthand too- just use D (for Days), M (for Months), or Y (for Years).

Here're some examples:

// Crm.Sales.SalesOrders
10: DATEDIFF ATTRIB:DocumentDate ATTRIB:RequiredDeliveryDate CONST:Days

We have a Sales Order, and this will return the difference between the document date and the required delivery date in days.

Another one:

// Crm.Customers
10: DATESPAN ATTRIB:CreationTime EXP:20 CONST:Months

And this will display the number of months that have passed (because we're using DATESPAN) since a customer was created.


The DATESPAN operator is a significant advancement, enabling users to calculate time duration between dates with specified intervals.

It returns the difference between dates as a duration in the specified interval type. The interval is fulfilled when the same date and time is reached in the next interval.


The DATEDIFF operator addresses a crucial need for accurate representations of absolute date differences.

It returns the difference between dates as the absolute date difference for the specified interval type

I'm confused what's the difference?

Let's clarify with some examples.

2023-01-01 23:59
2023-01-02 00:01

That's a 2-minute difference. Now, let's consider the days "inside":

How many days do we have? 0 or 1?

DATESPAN will return 0 days because we don't have a period of a whole day.

DATEDIFF will return 1 day because that's the absolute difference.

Let's see another one,

2023-01-01 23:58
2023-01-02 23:58

As you've probably guessed, both operators will return 1 day.


  • DATESPAN: We have a full day.
  • DATEDIFF: Similar to the previous case, we're looking at the absolute difference between two days.


With these exciting operators added, beginning from version 24, Calculated Attributes takes a significant leap forward. It meets the needs of professionals across diverse domains, enabling you to explore new opportunities. Update now and unlock the potential of precise date manipulation!


More information is available in our official documentation:

Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk