Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to use TTimeStamp function?

Posted on 1998-03-12
5
Medium Priority
?
624 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 200 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

722 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