Solved

Time calculation

Posted on 2001-06-20
2
153 Views
Last Modified: 2010-04-06
Hi,  
How can I calculate how many minutes between now and 5 pm the same day ?
Thanks
0
Comment
Question by:frdep
  • 2
2 Comments
 
LVL 13

Accepted Solution

by:
Epsylon earned 100 total points
ID: 6211264
Try this:


var date1, date2, diffdate: TDateTime;
   difftime: TTime;
   hour , min, sec, msec: Word;
   ndays: Integer;
begin
 date1 := Date + EncodeTime(17, 0, 0, 0);
 date2 := Now;
 diffdate := date2 - date1;
 ndays := Trunc(diffdate);
 difftime := diffdate - ndays;
 DecodeTime(difftime, hour, min, sec, msec);
 hour := hour + ndays * 24;
 ShowMessage(IntToStr(hour) + ' hours, ' + IntToStr(min) + ' minutes ' + IntToStr(sec) + ' seconds')
end;
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6211314
If you only need the minutes you can use this:

date1 := Date + EncodeTime(17, 0, 0, 0);
date2 := Now;
ShowMessage(IntToStr(Trunc(Abs(date2 - date1) * 24 * 60)));
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

912 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

16 Experts available now in Live!

Get 1:1 Help Now