Link to home
Start Free TrialLog in
Avatar of hidrau
hidrauFlag for Brazil

asked on

How inc ddd hh:mm:ss into my datetime?

Hello guys

I have a maskedit where I inform ddd hh:mm:ss and I want to inc my date, I tried this code and it works fine for days but not
for hours :(

For example:  001  02:35:40 add to my date 07/11/2017 13:00:00

procedure TFDatasPrevisao.MaskEdit1Exit(Sender: TObject);
var
  dias, horas, minutos, segundos : String;
  Dt   : TDateTime;
begin
  Dt       := MaskEdit1.DateTime;
  Dias     := Copy(MaskEdit3.text, 1,3);
  Horas    := Copy(MaskEdit3.text, 5, 2);
  Minutos  := Copy(MaskEdit3.text, 8, 2);
  segundos := Copy(MaskEdit3.text, 11, 2);

  if StrToInt( dias ) > 0 then
  Begin
    dt := IncDay(dt, StrToInt( dias ))
  End;

  if StrToInt( horas ) > 0 then begin
     dt := IncHour(dt, StrToInt( horas ))
  end;

  if StrToInt( minutos ) > 0 then begin
     dt := IncMinute(dt, StrToInt( minutos ));
  end;

  MaskEdit2.Date :=  dt;

end;

Open in new window


Whats is wrong? any clue for a better way?

thanks
Alexandre
SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hidrau

ASKER

Thanks a lot for the example and explanation