Solved

How to use TTimeStamp function?

Posted on 1998-03-12
5
577 Views
Last Modified: 2010-04-04
Hi...how do you use the TTimestamp type? What it says in the online help doesn't explain a thing! I keep getting a value of 0 in both the date field and time field. All I want to do is display to the user how long my program takes to run in seconds. Basically, I want to have a "begintime" value when my process starts running, then an "endtime" value when it's done. Then subtract begintime from endtime to get the elapsed time in seconds...nothing complicated.

Cheers
   Shawn Halfpenny
0
Comment
Question by:aztec
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
ID: 1360440
Hi aztec,

You can do it with this :
var ElapsedTime : TDateTime;

Begin
 ElapsedTime := Now;
 // compiling
 ElapsedTime := ElapsedTime - Now;
 ShowMessage('Elapsed time between compiling : '+TimeToStr(ElapsedTime));
End.

Regards, Zif.
0
 

Author Comment

by:aztec
ID: 1360441
But won't the TdateTime function just give me elapsed time in days and fractions of days? Like 0.065 days or something like that? That's no good, I need something that'll show seconds and fractions of seconds.

Any suggestions?

Shawn
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360442
Nope, TDateTime is splitted in a date and time part. (doubles)

Delphi stores date and time values in the TDateTime type. The integral part of a TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of a TDateTime value is the time of day.


So when you put
ElapsedTime := Now ( the hours, minutes, seconds, month, year  will be filled in in the TDateTime)
If you use Time : Only hours, minutes, seconds will be filled in
By Date : only month year and day will be filled in

Usind TimeToStr will give the hour in a certain format.
0
 

Author Comment

by:aztec
ID: 1360443
You're right...it does the trick..thanks!

Cheers
   Shawn

P.S: Your "e-mail notification check" doesn't work! You know..that place where you can put a check mark if you'd like e-mail notification whenevr a question is updated ..?
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360444
? My "e-mail notification check"
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question