Solved

Time calculation

Posted on 2001-06-20
2
160 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
[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
  • 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

729 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