If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Convert hours into DD:HH:MM format

Started by SarahCL, 13 Aug 2015 04:12:36 PM

Previous topic - Next topic

SarahCL

Hi all!

New day new challenge. I have a column in my report that is in hours. Client wants to see in x days, x hours, x minutes

I used this link to http://www-01.ibm.com/support/docview.wss?uid=swg21339322 to help so my data items are as follows:

[Days] : cast((floor([myField]/24)), varchar(10))
[Hours] : cast(floor(([myField]-(floor([myField]/24))*24)), varchar(10))
[Minutes] : cast(([myField]-(floor([myField]/60)*60)), varchar(10))

but I am realizing that it is not pulling a correct result. # days look right, # hours are right but # minutes are off (left the decimals on purpose). It looks like the minutes are just mirroring one number before the decimal point and the decimals. Doesn't look like it is calculating anything.

Anyone as a simpler solution or can tell me whats is wrong with the minutes calculation?

BigChris

couldn't you do the minutes calculation as ([myField] - ([Days] *24) - [Hours]) * 60 ?

SarahCL

#2
That worked!

Thank you so much! Although now I cannot get rid of the decimals with "floor"

BigChris

what happens if you try doing the calculation without the cast? What do you get from the following:

Days: floor([myField]/24)
Hours: floor([myField]-floor([myField]/24)*24)   or
Hours: floor([myField] - [Days] * 24)
Mintues: ([myField] - ([Days] *24) - [Hours]) * 60

SarahCL

#4
Looks good too but my minutes still have lots of decimals I would like to trim

ETA: forgot my _round...

all good thanks!