Solved

# Timer question

Posted on 2001-07-09
Medium Priority
201 Views
I want my Label1 shows now + 25 min. How can i do this?

When i do TimeToStr(Now) + 25 it gives error??
0
Question by:systemop

LVL 5

Accepted Solution

TheNeil earned 120 total points
ID: 6264189
TDateTime is a float value. The integer part gives the day and the decimal part gives the time. To add 25 minutes then you need to do this:

Label1.Caption := TimeToStr(Now + EncodeTime(0, 25, 0, 0));

You can't just ass 25 straight onto the time as that's not how it works. The above does

The Neil =:)
0

LVL 5

Expert Comment

ID: 6264193
Sorry, that should be 'add' not 'ass'

The Neil =:)
0

LVL 22

Expert Comment

ID: 6264196
procedure TForm1.Button1Click(Sender: TObject);
var
Hour, Min, Sec, MSec: Word;
begin
DecodeTime(Time,Hour,Min,Sec,MSec);
Label1.Caption :=IntToStr(Hour) + ':' + IntToStr(Min + 25) + ':' + IntToStr(Sec);
end;
0

LVL 9

Expert Comment

ID: 6264208
Hi systemop,

const
OneHour = 1/24;
OneMin = OneHour / 60;
....
TimeToStr(Now+ 25*OneMin)

-----
Igor.
0

Author Comment

ID: 6264236
Thanks man youre my hero..
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Integration Management Part 2
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
###### Suggested Courses
Course of the Month9 days, 3 hours left to enroll