DATEDIFF
Description:
This function is used to get the difference of two dates.
Syntax:
DATEDIFF (String_Expression , Scalar_Expression1 , Scalar_Expression2)
Return type:
SCALAR
Parameters:
Parameter | Description |
|---|---|
String_Expression | This value specifies the unit called as interval, in which the difference needs to be evaluated, Supported Intervals- year, month, quarter, week, day, yyyy, yy, mm, m, qq, q, ww, w, dy, d. |
Scalar_Expression1 | This value defines the start date. |
Scalar_Expression2 | This value defines the end date. |
Example:
WITH MEMBER [Measures].[Days Since Order] AS
DateDiff('d', CDate([Date].[Calendar].CurrentMember.Name), Now())
SELECT
[Measures].[Days Since Order] ON COLUMNS,
[Date].[Calendar].[Date].Members ON ROWS
FROM [AdventureWorksMF_ValueBased]