From: ralph on
On Fri, 25 Jun 2010 07:34:11 -0400, "Jack B. Pollack" <N(a)NE.nothing>
wrote:

>Using VB 6 I want to compare two times, a time stamp and the current time.
>The timestamp will always be on the same date as the current date so I dont
>have to compare the date part (but can if it is easier)
>
>I can break the time apart and use datepart() but there has to be a simpler
>way.
>
>eg: if time-timestamp < 5 min then ...
>

Depends on how these dates are stored, and how close to "equality" you
need.

Date datatypes are stored as a floating point number.
The integer portion is the number of days from
The decimal portion is the proportion of time from Midnight to
Midnight.

So if the times are far enough apart you can use straight comparison
operators, but if you need to test for equality or the exact second or
lwer - then you will run into scale problems (ie, 55 minutes can have
more that one 'decimal' equivalent.)

The first thing you need to resolve is where the dates are coming from
and their datatype. The second is the degree of difference you can
tolerate.

It is possible that while DataPart may be slower, it may be the only
accurate way.

-ralph