Solved

Time calculation

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…

739 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