Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How to format an int as time ?
ead
Hi
I have something like a counter for seconds, now I want to see it format as HH:MM:SS
so like 65 will be like 00:01:05
And so om
How can it be done please?
Find more posts tagged with
Comments
mwilliams
Hi ead,
If you have a column in your dataSet of these "seconds" values called row["Seconds"], all you need to do is create a computed column in your dataSet, set the type to time, and use the following as the expression, you should get what you want.
new Date(0,0,0,0,0,row["Seconds"]);
When you put this in a table, you'll need to select the data item from the detail row, go to the property editor, then to the FormatDateTime section, and use the custom format of 'HH:mm:ss' to make it 24 hour time, otherwise, you'll end up with "12:01:05".
Let me know if you have any questions on this.
ead
Amm that is cool!
So, just use a compuned cell?
And how is that?
mwilliams
ead,
To create a computed column in your dataSet, you just open up your dataSet editor from the data explorer window by double clicking on it, then go to the computed columns section and click on the "new" button. If you just have one integer value you want to put in this format, you could use the same idea in a data element.
ead
Ok I hope it will work.
Right now I have just made a function in Java for doing it, not so nice I guess
mwilliams
ead,
Let me know.
ead
I get 12:00:00 AM in all my cells (and I do have data that in Seconds)
What is wrong?
mwilliams
ead,
Can you attach your report design?
What version of BIRT are you using?
ead
last stable version from the site
Why?
mwilliams
ead,
I asked what version you're using, so that when you posted your report design (if you can), I could for sure open it.
mwilliams
ead,
I can also post a sample report that shows how I did it if I knew the version you were using. It would be helpful to me in explaining to you what you need to do if I see your setup though. I'm assuming you're using 2.3.1.
ead
Ok, but I am using my DB, not a sample one
How will u use it ?
mwilliams
ead,
I would just look at what you've done in your report design. If you can't post it for company reasons, that's fine. I'll make a quick example of how I'm using an integer seconds value from a dataSet to get the report to display it as HH:mm:ss.
mwilliams
ead,
Here you go. I've attached a report design made in BIRT 2.3.1 and a screenshot showing what I did to make the format the correct way. I used a computed column to make an integer value of 65 for seconds, made a computed column to make the integer a time value, and then used the formatDateTime feature to make it display correctly. Hope this helps.
ead
I can't read this file
Seem like a wrong version.
I am using 2.2.2 version of BIRT.
mwilliams
ead,
Save and open the report design. In the XML source, change all the version information to match the version information for BIRT 2.2.2. You can find that info in the XML Source of a report you created with BIRT 2.2.2.