PDA

View Full Version : How to subtract two time


Mujaidin
07-03-2009, 10:08 AM
How to subtract two time

exemple : 9:10 - 18:05 = 9:15 (9 hours and 15 minutes)

Help me please, sorry i dont speach Englis very well...

Samuel
07-03-2009, 02:58 PM
Var
d1, d2 : TDatetime;
Begin
d1 := StrToTime('09:10');
d2 := StrToTime('18:05');
ShowMessage(TimeToStr(d1-d2));
End;

Mujaidin
07-06-2009, 11:19 AM
Var
d1, d2 : TDatetime;
Begin
d1 := StrToTime('09:10');
d2 := StrToTime('18:05');
ShowMessage(TimeToStr(d1-d2));
End;


tanks 1.000 x info:)

Ivan
12-20-2010, 10:43 AM
Hey its a very informative forum to solving our math solution with in just few second.

Lightkillar3
04-17-2011, 07:55 AM
good post,interesting

emailx45
08-16-2012, 06:28 PM
Dear friends,

The TDateTime = 1 part Integer (days) and 1 part Float Point (Hours)

So, you can to do CALCULATIONS with a var TDateTime directly.

Use HELP from Delphi for more informations, for FUNCTIONS as:

Format(), DateTimeToSTR(), etc....