DateTime hours "overflow" after 24h

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Messie
Newbie
Newbie
Posts: 34
Joined: Wed Apr 13, 2005 4:00 am
Location: Goettingen, Germany

DateTime hours "overflow" after 24h

Post by Messie » Tue Nov 27, 2007 1:53 pm

Hi,

I need to display a DateTime axis where the labes show hours and minutes.
I found no way to display e.g. 26h as 26:00. Is there any workaround for that? I would accept to get 1d 2h 0m, but the calculation always starts at the 30. (december 1899) so I get 31:02:00.
I already have caught the data in the OnGetAxisLabel Event and tried to use global variables to change the LabelText. This did not work because I can't see any system in the order of the incoming values.
Would be fine to fix that.

Thanks, Messie


TeeChart Pro 7.07 w/o code :(

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Wed Dec 05, 2007 11:05 am

Hi Messie,

If we understand well, you would like to start a timer when your application starts and add your points with date relative to this start or relative to one known date. So, you could subtract the initial date from the date at the moment of the point addition to obtain the relative date.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

PascalKlaus
Newbie
Newbie
Posts: 7
Joined: Thu Oct 18, 2007 12:00 am

Post by PascalKlaus » Tue Dec 11, 2007 2:43 pm

This is a formatting problem. 36 h are 1.5 in datetime format. If you format this with FormatDateTime('dd - hh:nn',1.5) it will Return 31 - 12:00
(31 from 31.12.1899 (thats day 1))

use this instead of FormatDateTime:

Code: Select all

function GetTimeDiffStr(dTimeDiff:TDateTime):string;
var
  sDays:string;
begin
  if Abs(dTimeDiff) >= 1
    then sDays := IntToStr(trunc(Abs(dTimeDiff))) + ' - '
    else sDays := '';
  Result := sDays + FormatDateTime('hh:nn:ss',Abs(dTimeDiff));
end;
GetTimeDiffStr(1.5)
and you will get "1 - 12:00"

Post Reply