We're excited to let you know that starting from version 24 of Calculated Attributes, we've introduced two highly anticipated operators:
DATESPAN and DATEDIFF.
These additions fulfill a long-awaited need – precise and efficient date manipulation.
Let's skip to the point.
Their usage is straightforward:
10: DATESPAN STARTDATE ENDDATE INTERVAL
10: DATEDIFF STARTDATE ENDDATE INTERVAL
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:
10: DATEDIFF ATTRIB:DocumentDate ATTRIB:RequiredDeliveryDate CONST:Days
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.
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,
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: