time calculation

27 views
Skip to first unread message

Ibrahim AL-Fouzan

unread,
Mar 30, 2025, 10:54:25 AMMar 30
to Rosi Delphi Components
Hi Tomas,

in component dbgrid i want to calculate time in each column is that posible  
time format HH:MM
best regards

Tomas Rosinsky

unread,
Mar 31, 2025, 2:28:49 PMMar 31
to Rosi Delphi Components
Hi, 

my rDBGrid shows data from dataset fields in the similar way as standard DBGrid.

If you need to show any calculated values, you can add calculation to sql command or add calculated field to dataset and define custom code for calculation as well as display format. Then rDBGrid will show this field, but this field it is always in read-only mode.

I hope it helps
Tomas
Dne neděle 30. března 2025 v 16:54:25 UTC+2 uživatel ifo...@gmail.com napsal:

Ibrahim AL-Fouzan

unread,
Apr 1, 2025, 5:59:52 AMApr 1
to Rosi Delphi Components
I mean foter SUM of the dbgrid
like this :
legs= %SUM;B;Maroon;

Tomas Rosinsky

unread,
Apr 1, 2025, 4:19:29 PMApr 1
to Rosi Delphi Components
Hi, 
summary result is calculated also for DateTime field but it is not shown because it does not make sense to show summary in date format.
Summary of time means that result contains number of days (e.g. 2.5 means 2*24+12 hours.

You can easily define own format for summary by custom code in event OnGetSummaryResult.
Example for hours:minutes format:


procedure TrDBGrid1.gr1GetSummaryResult(Sender: TObject; F: TField; SummaryResults: TSummaryResults; TagStr: string; ForFooter: Boolean;
  var DisplayText: string);
begin
  if (F = DMData.qEmpHireDate) and (AnsiPos('%SUM', TagStr)>0) then
  begin
    DisplayText:=Format('%.2d:%.2d',[Trunc(SummaryResults.Sum*24), Round(Frac(SummaryResults.Sum*24)*60)]);
  end;
end;

I hope it helps
Tomas
Dne úterý 1. dubna 2025 v 11:59:52 UTC+2 uživatel ifo...@gmail.com napsal:

Ibrahim AL-Fouzan

unread,
Apr 3, 2025, 6:27:18 AMApr 3
to Rosi Delphi Components
Thank you very much Tomas very helpfull 
Reply all
Reply to author
Forward
0 new messages