Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time and Date 1

Status
Not open for further replies.

fergmj

Programmer
Feb 21, 2001
276
US
I need help finding a way to have a user select a start and a stop time. My app needs to begin capturing data when the current time equals the time the user indicated as a start time and stop when the stop time arrives. Any ideas?

Thanks for the help.

Mindy Ferguson
Associated Press
Washington
 
Just a suggestion off the top of my head:
Create you form that asks for the user to input the expected date and time as Strings. Add a Timer component to the form. Create an OnTimer handler for the Timer control. In this handler, you will need to check for the current date and time every so often. For example:
Code:
TDateTime TheTimeIs = Time();
String StrTimeIs = TimeToStr(TheTimeIs);

TDateTime TheDateIs = Date();
String StrDateIs = DateToStr(TheDateIs);

if ((StrDateIs == UserEnteredDate) && (StrTimeIs == UserEnteredTime))
{
    // Then do something
}

You will also have to loop though thie timer sequence if the above isn't true. Like I say, this is just off the top of my head and it may or may not work depending on what you are trying to accomplish.

James P. Cottingham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top