Solved

How to use TTimeStamp function?

Posted on 1998-03-12
5
586 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Title # Comments Views Activity
Find and Replace Stream with 0s 8 71
FMX and jaudiotracker playing memory stream 29 97
Dynamically Created Query 3 69
how to change, disabled button color FMX ? 1 48
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

685 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