Converting a Total Seconds variable (summary) to DD:HH:MM:SS

Hello community. I'm using TIBCO Jaspersoft® Studio 6.6.0.

My report has a variable that sums the number of seconds of the records listed.

In the summary group, I need to display this variable ($V{total_seconds}) with the format DD:HH:MM:SS.

How should I do?

Many thanks.

mamelimail-jaspersoft@yahoo.com.br's picture
Joined: Feb 21 2017 - 9:29am
Last seen: 1 year 11 months ago

I solved using another post. Thank you.

mamelimail-jaspersoft@yahoo.com.br - 4 years 10 months ago

1 Answer:

This might not be a clean approach, but provides for your requirements,

Just copy this into your text field in report and replace $V{Report_TotalDuration} with your seconds variable

CONCATENATE(String.valueOf(INTEGER_VALUE(new DecimalFormat("#,##0").format( Math.floor($V{Report_TotalDuration}/(24*3600))))),'days:',INTEGER_VALUE(new DecimalFormat("#,##0").format(Math.floor($V{Report_TotalDuration}/60/60)% 24))<10? "0"+String.valueOf(INTEGER_VALUE(new DecimalFormat("#,##0").format(Math.floor($V{Report_TotalDuration}/60/60)% 24))):String.valueOf(INTEGER_VALUE(new DecimalFormat("#,##0").format(Math.floor($V{Report_TotalDuration}/60/60)% 24))),':',INTEGER_VALUE(new DecimalFormat("#,##0").format(Math.floor($V{Report_TotalDuration}/60) %60))<10? "0"+String.valueOf(INTEGER_VALUE(new DecimalFormat("#,##0").format(Math.floor($V{Report_TotalDuration}/60) %60))):String.valueOf(INTEGER_VALUE(new DecimalFormat("#,##0").format(Math.floor($V{Report_TotalDuration}/60) %60))),':',INTEGER_VALUE(new DecimalFormat("#,##0").format(Math.floor($V{Report_TotalDuration} % 60)))<10? "0"+String.valueOf(INTEGER_VALUE(new DecimalFormat("#,##0").format(Math.floor($V{Report_TotalDuration} % 60)))):String.valueOf(INTEGER_VALUE(new DecimalFormat("#,##0").format(Math.floor($V{Report_TotalDuration} % 60)))))

mjmapi's picture
176
Joined: Oct 6 2015 - 2:14am
Last seen: 4 months 1 week ago
Feedback