How to format time value in HH: MM: SS in datalabel

So, I have a histogram in crystal reports. In this graph, I have a data label attached to each of the graphs that displays the graph value in seconds, which looks like this: enter image description here What I would like to do is format this data label into time formatting. Therefore, for each column on the chart, a data label will be displayed in the following format:

HH: MM :. FROM.

I can get the time formatting using the following formula:

local NumberVar Sec; local NumberVar ss; local NumberVar mm; local NumberVar hh; local StringVar SSS; local StringVar MMM; Sec := Sum ({GetAlarmSummaryDataSet2Response/GetAlarmSummaryDataSet2Result/Items/AlarmSummaryItem2.StopTime}, {GetAlarmSummaryDataSet2Response/GetAlarmSummaryDataSet2Result/Items/AlarmSummaryItem2.Section}) ; hh := Int (Sec/3600); mm :=Int ((Sec/60)- (60* Int(Sec/3600 ))); If mm<10 then MMM := "0" & ToText (mm,0); If mm>9 Then MMM := ToText(mm,0) ; ss :=Sec-(3600 * hh ) - (60 * mm ) ; If ss<10 then SSS := "0" & ToText (ss,0); If ss>9 Then SSS := ToText(ss,0) ; ToText ( hh,0) & ":" & MMM & ":" & SSS 

But I'm not sure how to implement this formula on a data label.

Any help or suggestions are welcome.

thanks

+6
source share
1 answer

You can choose to display the group name, and you can display and format the total value calculated on the chart, but you cannot provide your own formula. This is simply not possible using the chart library in CR XI.

My possible workaround for this problem:

  • Modify the value formula to eliminate the aggregate function. (This is necessary because Crystal does not allow the aggregate function in the group name field - see # 2.)
  • For the group name, specify the formula with the text that you want to display in the riser. Include both the label and the formatted value, separated by Chr(13) & Chr(10) , to put them on separate lines.
  • Adjust the riser to display the label, not the value.

To apply this to your problem, you need to make the following changes:

  • Eliminate the aggregate function. Of course, I donโ€™t know if this will be possible with your setup. Perhaps if you are using a DBMS, you can use the SQL command or stored procedure to calculate the amount before the data reaches Crystal.
  • Print the label and value together, either on a riser or on the X axis.

If this is not suitable for your application, you may consider CRChart , a commercial replacement that attempts to remove the limitations of crystal libraries. (I thought it was too expensive.) I think the @APPEND_DATATEXT macro will allow you to place your own value on the riser, but you still need to move the summary to the server.

+1
source

Source: https://habr.com/ru/post/898542/


All Articles