dbTalk Databases Forums  

DateDiff

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss DateDiff in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Michael Morse
 
Posts: n/a

Default DateDiff - 11-04-2003 , 08:45 AM






Does anyone no why when I use the DateDiff function in a calculaetd member
that it returns a off the wall decimal number? Instead of the actual
difference in days?

I'm storing dates as DateTime in format of 1/1/2003

-mike



Reply With Quote
  #2  
Old   
Michael Shao [MSFT]
 
Posts: n/a

Default RE: DateDiff - 11-05-2003 , 01:16 AM






Hi Michael,

Firstly, I would like you to check to see your expression with DateDiff
function is able to work fine using Query Analyzer. You can get the actual
difference in days.

Then, I think we do not need to use calculated measure to meet your
requirements. We can try to define a measure to show the actual difference
in days. In the property of this measure, we try to type the following
statements in the "source column" box on the Basic tab:

DateDiff(d,"dbo"."Orders"."OrderDate", "dbo"."Orders"."ShippedDate")

"dbo"."Orders"."OrderDate is the column name in the Orders table in the
Northwind database.
"dbo"."Orders"."ShippedDate" is the column name in the Orders table in the
Northwind database.

Set the Data Type to be Integer and the Display Format to be standard on
the advanced tab in the measure property. Then process the cube and I can
get the expected data on my side.

Please feel free to post in the group if this solves your problem or if you
would like further assistance.

Regards,

Michael Shao
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Reply With Quote
  #3  
Old   
vanchi
 
Posts: n/a

Default DateDiff - 11-06-2003 , 12:26 AM



Hi,
Usually to get the DateDiff in Calculated member,we have
to cast both dates into Integer then do the substraction.
It will give exact results in Days.
I think it will work.
Pls try this way.
Regards,
Vanchi
Quote:
-----Original Message-----
Does anyone no why when I use the DateDiff function in a
calculaetd member
that it returns a off the wall decimal number? Instead of
the actual
difference in days?

I'm storing dates as DateTime in format of 1/1/2003

-mike


.


Reply With Quote
  #4  
Old   
Vanchi
 
Posts: n/a

Default RE: DateDiff - 11-06-2003 , 02:34 AM



Hi Michael Shao,
Your method will work when both the dates are taken from
the same row of the record.
If I need to take from different rows,
For example
PONO Product OD DD
1 1 10/11/2003 13/11/2003
1 2 11/11/2003 15/11/2003
Here i want to find the DateDiff for Product
and DateDiff for PONO.
How to get the DateDiff using same measure.
In this case,You have to create Measure1 for OD as Cast(OD
as int) with Agg function as Min
create Measure2 for DD as Cast(DD as int) with Agg
Function as Max
Then create Calculated Measure as Measure2-Measure1
This is the way you can get the DateDiff for differnt
dimentions using the same Measure.

Am I right.

Pls comment.

Vanchi.

Quote:
-----Original Message-----
Hi Michael,

Firstly, I would like you to check to see your expression
with DateDiff
function is able to work fine using Query Analyzer. You
can get the actual
difference in days.

Then, I think we do not need to use calculated measure to
meet your
requirements. We can try to define a measure to show the
actual difference
in days. In the property of this measure, we try to type
the following
statements in the "source column" box on the Basic tab:

DateDiff
(d,"dbo"."Orders"."OrderDate", "dbo"."Orders"."ShippedDate"
)
Quote:
"dbo"."Orders"."OrderDate is the column name in the
Orders table in the
Northwind database.
"dbo"."Orders"."ShippedDate" is the column name in the
Orders table in the
Northwind database.

Set the Data Type to be Integer and the Display Format to
be standard on
the advanced tab in the measure property. Then process
the cube and I can
get the expected data on my side.

Please feel free to post in the group if this solves your
problem or if you
would like further assistance.

Regards,

Michael Shao
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and
confers no rights.

.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.