Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Decimal to Hours:Minute conversion
Decimal to Hours:Minute conversion [message #684444] Wed, 15 June 2011 15:17 Go to next message
Gopi  is currently offline Gopi Friend
Messages: 10
Registered: May 2011
Junior Member
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 #684510 is a reply to message #684444] Wed, 15 June 2011 17:26 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

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 Go to previous messageGo to next message
tlchristian is currently offline tlchristianFriend
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 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

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.
Previous Topic:skip ODA lib script in design time
Next Topic:JDBC error
Goto Forum:
  


Current Time: Thu Mar 28 21:01:48 GMT 2024

Powered by FUDForum. Page generated in 0.03521 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top