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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking Time Values

Status
Not open for further replies.

pgk

Programmer
Jul 19, 2002
262
US
Hi Folks,
I would like to know the best method of determining whether a start time is greater than the end time.

EG. Start Time 23:30 End Time 1:30

This problem becomes important when scheduling tasks using my application.
Any help would be very much appreciated. Thanks in advance.

Hope it helps. Let me know what happens.
With regards,
PGK
 
Hi

You could use DateDiff() - see below - and by testing the sign of the reslut determe which is the 'greater':

Example

debug.Print DateDiff("s",CDate("01/01/01 21:30"),Cdate("02/01/01 20:00"))
81000
debug.Print DateDiff("s",CDate("01/01/01 21:30"),Cdate("01/01/01 20:00"))
-5400 Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi,
Thanks for the suggestion. But is it possible to use just the time alone to perform this operation?

Hope it helps. Let me know what happens.
With regards,
PGK
 
Hi

Surely you need to know if the times are in the same day (ie date) in order to know if it is after of before.

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
You can use only time - &quot;01:30&quot; is the same as &quot;1899.12.30 01:30&quot; - and DateDiff works correctly. You can even compare dates (or times) using &quot;>&quot; or &quot;<=&quot; - actually date is double number - count of days after &quot;1900.01.01 00:00&quot;. Time is stored in fractional part.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top