Page 1 of 1

DateTime hours "overflow" after 24h

Posted: Tue Nov 27, 2007 1:53 pm
by 9236620
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 :(

Posted: Wed Dec 05, 2007 11:05 am
by yeray
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.

Posted: Tue Dec 11, 2007 2:43 pm
by 10547065
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"