We help IT Professionals succeed at work.

i need to get the time value from a decimal Value

Tech_Men
Tech_Men asked
on
Medium Priority
392 Views
Last Modified: 2012-05-06
for example if i have decimal value : 14.90
i need to get the time value that is : 15.30 HH.MM
how can i do it in the report ?
thanks
Comment
Watch Question

Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
Can ypu give other examples?

Generally values like that are 14 hours and .9 of an hour or 54 minutes so it it 14:54
If it really is 15.30 then what is 15.3 in your database?

mlmcc

Author

Commented:
14.90 its 14 hours and 90 min
from the 90 min we have 1 hour + 30 min
so we have 14 + 1.30 = 15.30
this is waht i need to calc
i hope that u help me...

Commented:
Try this:
Assuming @time1 is the original time value,

floor({@time1},1) + floor((({@time1} - floor( {@time1})) * 100 / 60))
+
(
   (
    ({@time1} - floor( {@time1})) * 100 -
    (floor(({@time1} - floor( {@time1})) * 100/60) * 60)
   )
  / 100
)

It SEEMS to work....

Author

Commented:
in the report i made a formula whit this code :

floor(Sum ({Msam.TotalHour}),1) + floor(((Sum ({Msam.TotalHour}) - floor( Sum ({Msam.TotalHour}))) * 100 / 60))
+
(
   (
    (Sum ({Msam.TotalHour}) - floor( Sum ({Msam.TotalHour}))) * 100 -
    (floor((Sum ({Msam.TotalHour}) - floor( Sum ({Msam.TotalHour}))) * 100/60) * 60)
   )
  / 100
)
but i am geting this message :
The remaining text does not appear to be part of the formula.

Commented:
You should have cut/pasted my formula.
For one thing, you have 3 right parens on the end of your first line, where I have 2....

Author

Commented:
Sum ({Msam.TotalHour})  in here i have the value that need to turn it to time
can u type it in youer forumla and send it here fix?
thanks ..

Commented:
Create a formula field named time1, and set its value to "Sum ({Msam.TotalHour})"
Then just use my formula.

Author

Commented:
i creatd a formula called @time1
inside it i put this code :
Sum ({Msam.TotalHour})

what know ?
Commented:
Now, create the calculated time formula using the formula I gave you above:
floor({@time1},1) + floor((({@time1} - floor( {@time1})) * 100 / 60))
+
(
   (
    ({@time1} - floor( {@time1})) * 100 -
    (floor(({@time1} - floor( {@time1})) * 100/60) * 60)
   )
  / 100
)

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
i need to creat a new formula ?

Author

Commented:
i cretad n new formula call : CalcTime
and i put youer code into
then i drag the calc formula into the report
when i run the report i am geting this Exsption :
 
Error in File C:\DOCUME~1\simon\LOCALS~1\Temp\temp_b75aadc1-f54d-407a-854f-30353b8eb028 {203C465B-CB5C-4A40-8D7E-486F1A90E4E4}.rpt:
Error in formula  <@Calc>.
'floor({@time1},1) + floor((({@time1} - floor( {@time1})) * 100 / 60))
'
The remaining text does not appear to be part of the formula. ---> System.Runtime.InteropServices.COMException (0x80041019):
Error in File C:\DOCUME~1\simon\LOCALS~1\Temp\temp_b75aadc1-f54d-407a-854f-30353b8eb028 {203C465B-CB5C-4A40-8D7E-486F1A90E4E4}.rpt:
Error in formula  <@Calc>.
'floor({@time1},1) + floor((({@time1} - floor( {@time1})) * 100 / 60))
'
The remaining text does not appear to be part of the formula.
 

Author

Commented:
someone ?
Senior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013
Commented:
Are you using Crystal or Basic syntax in your formulas?

You should use Crystal syntax.

Here is a slightly easier formula

local numbervar time1 := {@time1};

local numbervar hours1;
local numbervar minutes1;
hours1 := truncate(time1);
minutes1 := time1 - hours1;
minutes1 := minutes1 * 100;
if minutes1 >= 60 then
(
    hours1 := hours1 + 1;
    minutes1 := minutes1 - 60;
);
hours1 + minutes1/100  

mlmcc

Author

Commented:
A++
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.