So Let's Get into Situation if you need a small tool like Converting Time Fraction from NAV standards Like 1.98 hours to 1 hour and 58 mins...
You might want to represent as 1:58 So to achieve that..
i would like to implement a CodeUnit .Let's Declare a CodeUnit Time Calculator ..
Lets Create a Function Say ConvToHour and property of function Local to NO like Below...
select Function and Click Locals and define a Parameter of datatype Decimal...
Next we want to return a text like 1:58 in my example to calling place. So Set return Type to TEXT..
You can also return return as Time Datatype....
So now we should declare a Local String Variable which we wanted to send back...after Modifications Of Course..
Now write the Logic for converting...
Not Using any Alien Tech functions Just Using a ROUND Function ,I hope you may came across..
For Begginers Sample: ROUND(11.9) = 11
In Above I'm Calling the Function which Would return text so directly Displaying that in Message Function...
hrs := ROUND(TimeinDec,1,'<');
//IN Above statement we would get hours...
//Getting 0.98 and Converting 0.98 fraction into minutes i.e 0.98 * 60 = 58.80
frac_req_Min := TimeinDec - hrs;
min := ROUND(60 * frac_req_Min,1,'<');
//Getting 0.80 and Converting 0.80 fraction into minutes i.e 0.80 * 60 = 48 sec
frac_req_secs := (60 * frac_req_Min) - min;
secs := ROUND(60 * frac_req_secs,1,'<');
//Converting Integer to String as we cant directly send 1:58 isn't it
Str := FORMAT(hrs);
//converting Minutes to string
IF min > 9 THEN
Str := Str + ':' + FORMAT(min)
Str := Str + ':0' + FORMAT(min);
//converting Secs to String
IF secs > 9 THEN
Str := Str + ':' + FORMAT(secs)
Str := Str + ':0' + FORMAT(secs);
//Just To Test
//You Could convert it to Time if needed
//This is to return from where you calling....Hope you understand...
Screen shot of Code...
Let me Know if you have any Queries....