• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 680
  • Last Modified:

Counting total days between two dates

I have two dates in my cube, date1 and date2.  I need to count days between those two dates and then sum the result by year basis. I have created a similiar scenario on the Adwenture works cube where I'm trying to show total of days between ship date and delivery date and then show the result by each year by category. I get #error in the 2005 and 2006 measure, how can I show the correct result?

WITH 


MEMBER [Measures].[Ship Date] AS [Ship Date].[Date].membervalue
MEMBER [Measures].[Delivery Date] AS [Delivery Date].[Date].membervalue
MEMBER [Measures].[# of Delivery Days] AS [Measures].[Delivery Date] - [Measures].[Ship Date]
MEMBER  [Measures].[2005] as SUM([Measures].[# of Delivery Days],[Ship Date].[Calendar].[Calendar Year].&[2005])
MEMBER  [Measures].[2006] as SUM([Measures].[# of Delivery Days],[Ship Date].[Calendar].[Calendar Year].&[2006])

SELECT	{
	
[Product].[Category].[Category]
	} ON COLUMNS,
	
	( {[Measures].[2005],[Measures].[2006]}

	) ON ROWS
FROM	[Adventure Works]

Open in new window

0
gosi75
Asked:
gosi75
  • 2
1 Solution
 
plusone3055Commented:
have your tried using the DATEDIFF Function ?

here is an explanation of DATEDIFF function and what it does via MIcrosoft :)

http://technet.microsoft.com/en-us/library/ms189794.aspx
0
 
gosi75Author Commented:
I'm using OLAP so I don't think DATEDIFF will work for me. Any other succession :)
0
 
gosi75Author Commented:
I did use datediff, but I added it to my cube as a measure.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now