I have some code that uses DateSerial to populate a couple of text boxes on
a form. I was doing some testing this afternoon and found that I get funny
values if the year supplied is 99. 98 works fine. 04 works fine. 1999 works
fine. 100 works fine. But 98 gives a funny value. Anyone have thoughts on
why, or how to re-form the dateserial call to deal with this?
Here's some results from the immediate window:
?(DateSerial(98 , 12+ 1, 1)) - 1
12/31/1998
?(DateSerial(99 , 12+ 1, 1)) - 1
-657435
?(DateSerial(10 0 , 12+ 1, 1)) - 1
12/31/100
?(DateSerial(04 , 12+ 1, 1)) - 1
12/31/2004
Here's the line I use in code:
Me!txtEnd = DateSerial(intY earEnd, intMonthEnd + 1, 1) - 1
For the values above that give legit dates, it works fine, of course. But
for 99, I get 12/30/1899. Clicking in the field gives 12:00:00 am. It looks
to me as if it's coming up with some equivalent to zero, but I can't figure
out why. I suppose I could deal with error checking at the control level,
but I was hoping to avoid that (the code is currently in a function that
gets called from several places).
Jeremy
--
Jeremy Wallace
AlphaBet City Dataworks
a form. I was doing some testing this afternoon and found that I get funny
values if the year supplied is 99. 98 works fine. 04 works fine. 1999 works
fine. 100 works fine. But 98 gives a funny value. Anyone have thoughts on
why, or how to re-form the dateserial call to deal with this?
Here's some results from the immediate window:
?(DateSerial(98 , 12+ 1, 1)) - 1
12/31/1998
?(DateSerial(99 , 12+ 1, 1)) - 1
-657435
?(DateSerial(10 0 , 12+ 1, 1)) - 1
12/31/100
?(DateSerial(04 , 12+ 1, 1)) - 1
12/31/2004
Here's the line I use in code:
Me!txtEnd = DateSerial(intY earEnd, intMonthEnd + 1, 1) - 1
For the values above that give legit dates, it works fine, of course. But
for 99, I get 12/30/1899. Clicking in the field gives 12:00:00 am. It looks
to me as if it's coming up with some equivalent to zero, but I can't figure
out why. I suppose I could deal with error checking at the control level,
but I was hoping to avoid that (the code is currently in a function that
gets called from several places).
Jeremy
--
Jeremy Wallace
AlphaBet City Dataworks
Comment