Solved

Time calculation

Posted on 2001-06-20
2
161 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses
Course of the Month6 days, 8 hours left to enroll

634 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