473,395 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DateSerial

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(100 , 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(intYearEnd, 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
http://www.ABCDataworks.com

Nov 12 '05 #1
5 2627
"Jeremy Wallace" <ab**********@AlphaBetCityDataworks.com> wrote in
news:tI********************@speakeasy.net:
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(100 , 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(intYearEnd, 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).


Er, why are you passing 2-digit years?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #2
Just testing. If it weren't for this oddity I could pretty much get away
without forcing four-digit entry in this text box--I'm okay with the
windowing that goes on with two-digit years. But this thing with the 99 is
strange. Have you seen it before?

--
Jeremy Wallace
AlphaBet City Dataworks
http://www.ABCDataworks.com
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@24.168.1 28.86...
"Jeremy Wallace" <ab**********@AlphaBetCityDataworks.com> wrote in
news:tI********************@speakeasy.net:
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(100 , 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(intYearEnd, 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).


Er, why are you passing 2-digit years?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc

Nov 12 '05 #3
"Jeremy Wallace" <ab**********@AlphaBetCityDataworks.com> wrote in
news:AJ********************@speakeasy.net:
Just testing. If it weren't for this oddity I could pretty much
get away without forcing four-digit entry in this text box--I'm
okay with the windowing that goes on with two-digit years. But
this thing with the 99 is strange. Have you seen it before?


No, because I never allow 2-digit years, always forcing 4-digit.

Why?

Because the windowing behavior is dependent on a DLL that is not
part of the Access application I ship, and because on some OS's
(Win2K, WinXP, at least) it can be overridden by the end user to be
some behavior you don't expect.

Since I can't know what the window will be, I can never depend on
it.

To me, depending on the year window to interpret 2-digit years
correctly is like turning on AutoCorrect in a combo box -- you're
turning control over to a subsystem whose behavior you cannot
predict.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #4
I agree that it's turning control over to a subsystem I can't control, but
in this application there's no data entry, it's just reporting on data in
another database, so there can't really be any long-lasting impact from
putting in a wrong number--you'll just retrieve the wrong set of records.
All I'm looking for out of the windowing feature is that it be
consistent--that the user knows why it's doing what it's doing, or can
figure it out.

I am also really curious about this behavior.

--
=================
Jeremy Wallace
AlphaBet City Dataworks
ABCDataworks dot com
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@24.168.1 28.78...
"Jeremy Wallace" <ab**********@AlphaBetCityDataworks.com> wrote in
news:AJ********************@speakeasy.net:
Just testing. If it weren't for this oddity I could pretty much
get away without forcing four-digit entry in this text box--I'm
okay with the windowing that goes on with two-digit years. But
this thing with the 99 is strange. Have you seen it before?


No, because I never allow 2-digit years, always forcing 4-digit.

Why?

Because the windowing behavior is dependent on a DLL that is not
part of the Access application I ship, and because on some OS's
(Win2K, WinXP, at least) it can be overridden by the end user to be
some behavior you don't expect.

Since I can't know what the window will be, I can never depend on
it.

To me, depending on the year window to interpret 2-digit years
correctly is like turning on AutoCorrect in a combo box -- you're
turning control over to a subsystem whose behavior you cannot
predict.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc

Nov 12 '05 #5
CDB
AD99 is outside the scope of the Microsoft date-handling functions. But the
13th month IS in scope - Jan 1st, 100. One day before that is out of scope
again.

?(DateSerial(99 , 12+ 1, 1)) - 1
-657435

This is AD100 - within the scope.
?(DateSerial(100 , 12+ 1, 1)) - 1
12/31/100

A simpler expression is:
?(DateSerial(100 , 12+ 1, 0))

Day 0 is the day before day 1.

Clive
"Jeremy Wallace" <ab**********@AlphaBetCityDataworks.com> wrote in message
news:AJ********************@speakeasy.net...
Just testing. If it weren't for this oddity I could pretty much get away
without forcing four-digit entry in this text box--I'm okay with the
windowing that goes on with two-digit years. But this thing with the 99 is
strange. Have you seen it before?

--
Jeremy Wallace
AlphaBet City Dataworks
http://www.ABCDataworks.com


Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: PMBragg | last post by:
Thank you in advance. I'm trying to pull all inventory items from December of the previous year back to 4 years for my accountant. I know this can be done, but I'm drawing a blank. I've tried; ...
1
by: PMBragg | last post by:
ORINGINAL Post >Thank you in advance. I'm trying to pull all inventory items from December >of the previous year back to 4 years for my accountant. I know this can be >done, but I'm drawing a...
3
by: ralph_noble | last post by:
Greetings ... I have a table named Harms and Steven with a field named inspector (text) and inspection date (date/time). I need to count up how many times the inspector appears for any...
18
by: jimfortune | last post by:
I have an A97 module called modWorkdayFunctions in: http://www.oakland.edu/~fortune/WorkdayFunctions.zip It allows the counting of workdays taking into consideration up to 11 U.S. holidays. ...
1
by: Kenny | last post by:
I am having issues with the "Date.ToOADate" method in VB .NET. I understand that in VB6 the function DateSerial gives an internal representation of the date. When I use the DateSerial method in...
5
by: jerry.ranch | last post by:
I see that DateSerial can be used to "concatenate", in a way, three fields DateSerial(year, month day) into a date field (if year , month and date are numeric values). Unfortunately, my Month...
1
by: woooopa | last post by:
Something like this... MAX (DateSerial(!,!,!))
3
by: RZ15 | last post by:
Hi, I have a query that calculates the sum of branch transfers for the current quarter. Here is my Quarter-to-Date field: QTD-In: Sum(CCur(IIf(="TRN" And Between...
3
by: ringer | last post by:
On a form I have a combo where a month is entered. It shows the month names in column one, but it is bound to column two where each month's corresponding number is, ie Jan=1, Feb=2, etc. So...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.