Jump to content
Changes to the Jaspersoft community edition download ×

SEC_TO_TIME conversion


rajat.ray

Recommended Posts

How can i calculate miliseconds to HH:MM:SS format in iReport.

I can do this by executing this query

 

SELECT SEC_TO_TIME( SUM( SEC_TO_TIME( `totalTime` ) ) ) AS totalTime FROM individualprofiletable;

 

But when i execute this query in iReport it converts the output to 1/1/70 12:03AM.

 

Plz help me out.

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Hi

 

I posted the same problem last week. The only way I could convert unix timestamp to readable time was to create a static method in an external class mystuff.java:

 

public static String getSQLDate(Long today) {

 

Timestamp EndDate = new Timestamp(Long.parseLong(today+"")*1000);

return EndDate.toString();

}

 

In the text field expression call your method

mystuff.getSQLDate($F{CREATED_T}). set your tesx field expression class as a String.

 

Works for me

Cheers

Link to comment
Share on other sites

Brute force might be the best answer then. Create a String field with the expression:

 

Code:

new String ( ($F{totalTime}.longValue() / 3600) + ":" +
(($F{totalTime}.longValue() % 3600) / 60))

 

or something to that effect. If totalTime is milliseconds and not seconds just replace the hard coded constants with 3600000 and 60000.

 

-Barry

Link to comment
Share on other sites

Hi,

 

My query is like this:

 

And I want to convert individualprofiletable.totalTime into HH:MM:SS.

 

Select distinct individualprofiletable.firstname, individualprofiletable.middlename, individualprofiletable.lastname,individualprofiletable.totalTime,usertable.alias From individualprofiletable,registrationpintable,usertable where usertable.user_id=registrationpintable.user_id && individualprofiletable.userid=registrationpintable.user_id && college_name='vtu_college1';

 

Plz help me.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...