Solved

How to use TTimeStamp function?

Posted on 1998-03-12
5
569 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
oracle global variables 4 68
Tviruailstringtree sort multi columns on header click 1 62
How to build JSON File in Delphi 6 3 32
Delphi and Access based Enumeration 9 61
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

774 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