Solved

How to use TTimeStamp function?

Posted on 1998-03-12
5
553 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
? My "e-mail notification check"
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now