Print Page | Close Window

Seconds to HH:MM:SS /Crosstab Summary

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22302
Printed Date: 02 May 2024 at 5:49pm


Topic: Seconds to HH:MM:SS /Crosstab Summary
Posted By: NCGOV
Subject: Seconds to HH:MM:SS /Crosstab Summary
Date Posted: 03 May 2017 at 4:46am
Does anyone have a way to convert seconds to HH:MM:SS that will allow the time to be summarized in a crosstab?



Replies:
Posted By: DBlank
Date Posted: 03 May 2017 at 8:19am
I would rethink your request a bit.
leaving it as total seconds is easier to summarize.
You can add a display as over the top of that if you need to. Trying to summarize a display string of "hh:nn:ss" won't make much sense. Keeping it as a standard integer like total seconds would.
Also what happens if the total hours goes over 24? Does this also need to display one day + the time?


Posted By: NCGOV
Date Posted: 03 May 2017 at 8:27am
Thank you for the feedback.

I used the following formula in the display sting under the common tab -

local numbervar RemainingSeconds;
local numbervar Hours ;
local numbervar Minutes;
local numbervar Seconds;

Hours:=truncate(currentfieldvalue/3600);
RemainingSeconds:= currentfieldvalue - (Hours*3600);
Minutes:=truncate(RemainingSeconds/60);
Seconds:=currentfieldvalue - (Hours *3600)-(Minutes*60);

Totext (Hours, "00") + ":" + totext(Minutes, "00") + ":" + totext(Seconds, "00")


Posted By: DBlank
Date Posted: 03 May 2017 at 8:50am
Yes that is one way, assuming you never go over 99 hours. Again this is returning a string that is not really something you can summarize.



Print Page | Close Window