INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to get the value of the hour part of datetime

How to get the value of the hour part of datetime

(OP)
Hi,
I'm trying to calculate the total amount of the calls durations. I managed already to get sum of every call, and I get quite pretty result, for example:
2 days 3:43:23.

What I want to get, is to present the result in form:
51:43:23.

The way, I get the first result is:
CALCULATE;  
CREATE MEMBER CURRENTCUBE.[Measures].[Test]
 AS [MEASURES].[Call Dur],
FORMAT_STRING = IIF ([MEASURES].[Call Dur] < 1, 'hh:mm:ss',
'"' + cstr(int([MEASURES].[Call Dur])) + 'days "hh:mm:ss'),
NON_EMPTY_BEHAVIOR = { [Call Dur] },
VISIBLE = 1 ,  ASSOCIATED_MEASURE_GROUP = 'Fact Call Entry'  ;

I was trying using cint(hh) or cint('hh') inside the cstr expression, but this ends up with an error.

Does anybody has any idea, how to do this?
Thanks for any ideas.

RE: How to get the value of the hour part of datetime

You need to invoke the VBA functionality Using VBA!Function().

RE: How to get the value of the hour part of datetime

(OP)
Could you tell me, what should I pass as a parameter to that function? The transformation is done in a format_string property, and I have no idea, how to get an unformatted value of the time.

RE: How to get the value of the hour part of datetime

(OP)
Thank for your response, but unfortunatelly I still can't get it working. Trying get the number of hours using VBA!Hour() function seems not work.
Could you paste here a sample usage of the function in that context?

Thank in advance
Marcin Danek

RE: How to get the value of the hour part of datetime

How you would get the vallue greatly depends on what info is offered in the cube.  If you have a call start and a call end you would be better served calculating call duration outside of the cube and then just having the call duration be a sum of your records.
 

RE: How to get the value of the hour part of datetime

(OP)
Hi,
thanks for your answer.
Its exactly, what I have - the only one column with duration time. It's in a database as a filed of type time.
During creating a cube, I created new calculated field, which is just this duration converted to a single, so that I could perform calculations on it.
And what I want to do, is to display the total sum of call durations in a report or during browsing a cube. And that's the point, where I have a problem.

RE: How to get the value of the hour part of datetime

what is the underlying database?

RE: How to get the value of the hour part of datetime

(OP)
SQL Server 2008 Enterprise.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close