Solved

Time calculation

Posted on 2001-06-20
2
152 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

10 Experts available now in Live!

Get 1:1 Help Now