|
Re: Decimal to Hours:Minute conversion [message #684510 is a reply to message #684444] |
Wed, 15 June 2011 17:26 |
|
May be an easier way but you could do it like:
var hr =BirtMath.roundDown(6.5);
var rem = BirtMath.mod(6.5,hr);
var min = rem*60;
hr+":"+min;
This expression returns a string. Just replace 6.5 with your
row["columnname"]
Jason
On 6/15/2011 11:17 AM, Gopi wrote:
> Hi ,
>
> I have to change Decimal value to Hours:Minutes conversion.
> for Ex: Regularhrs = 6.50 (value stored in our database)
>
> I have to display this value to 6:30 (hh:mm).
> Please suggest how can I change decimal to hours:minutes
> Thanks in advance.
|
|
|
Re: Decimal to Hours:Minute conversion [message #734160 is a reply to message #684510] |
Thu, 06 October 2011 22:19 |
tlchristian Messages: 1 Registered: October 2011 |
Junior Member |
|
|
Yes, but what happens when hr=0? Birt returns an error because you have a 0 divisor in the BirtMath.mod statement.
Any workarounds for this? I'm trying to do the same thing, except I need days, hours, mins, and secs. So, if, say there are 10 days, 2 hours, 0 mins, and 4 seconds, the code won't work. I need a way to add additional statements to avoid the division by 0 error.
|
|
|
Re: Decimal to Hours:Minute conversion [message #734370 is a reply to message #734160] |
Fri, 07 October 2011 14:42 |
|
Try:
var hr =BirtMath.roundDown(0.5);
var rem = 0;
if( hr == 0 ){
rem = BirtMath.mod((0.5)+1,1);
}else{
rem = BirtMath.mod(0.5,hr);
}
var min = rem*60;
hr+":"+min;
replace the 0.5 with your column expression.
Jason
On 10/6/2011 6:19 PM, tlchristian wrote:
> Yes, but what happens when hr=0? Birt returns an error because you have
> a 0 divisor in the BirtMath.mod statement.
>
> Any workarounds for this? I'm trying to do the same thing, except I need
> days, hours, mins, and secs. So, if, say there are 10 days, 2 hours, 0
> mins, and 4 seconds, the code won't work. I need a way to add additional
> statements to avoid the division by 0 error.
|
|
|
Powered by
FUDForum. Page generated in 0.03521 seconds