Comparing dates with Time Stamps

Comparing dates with Time Stamps

Post by June » Sat, 02 Aug 2003 06:53:41

I have two date fields. I have to determine if the date
in one of the fields falls either before or on the same
day as the other field. I was using the following logic:

If MySet![Exp Arrival] <> 0 And MySet![DueDate] > MySet!
[Exp Arrival] Then
MySet![OnTime] = 1
ElseIf MySet![Exp Arrival] = MySet![DueDate] Then MySet!
[OnTime] = 1
MySet![OnTime] = 0

This worked fine before, however, the format of the data
that is being input into my database now has time stamped
information on it. If my duedate is 7/6/03 11:50 AM, and
my Exp Arrival is 7/6/03 12:01 PM, the above logic will
show that OnTime would be 0, when it should be 1. Is
there a way to work around this so I don't have to change
much code?

Comparing dates with Time Stamps

Post by Wayne Morg » Sat, 02 Aug 2003 07:27:17


should return just the date portion. Date/Time is actually stored as a number. The time is
the decimal portion.

Wayne Morgan
Microsoft Access MVP


Comparing dates with Time Stamps

Post by jfp » Sun, 03 Aug 2003 08:18:52

Int returns a 16 bit value -- you might need to convert it to a Long.
Not sure.

Comparing dates with Time Stamps

Post by Douglas J. » Sun, 03 Aug 2003 20:17:55

I'm not sure Int does return an integer (i.e. a 16 bit value). What it does
is return the integer part of the value. The Help file doesn't say that it
converts it to an Integer.

If you're concerned, try using the DateValue function:


number. The time is

Comparing dates with Time Stamps

Post by jfp » Tue, 05 Aug 2003 09:01:22

how interesting -- just another VB naming issue i suppose.
You are right -- Int() does NOT return an Int. Please do not confuse
with CInt() !!
For an argument of 65537.2 CInt() gave an overflow error but Int
returned 65537.

Comparing dates with Time Stamps

Post by June » Tue, 12 Aug 2003 22:09:17

Interesting...In my case, the Int(MySet![DueDate]) worked
just fine as I was comparing whether two dates were the
same (regardless of the time stamp). Thanks for all the
help guys!

not confuse
but Int

value). What it does
doesn't say that it