473,802 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Nov 12 '05 #1
5 2646
"Jeremy Wallace" <ab**********@A lphaBetCityData works.com> wrote in
news:tI******** ************@sp eakeasy.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(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).


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********@bwa y.net.invalid> wrote in message
news:Xn******** *************** ***********@24. 168.128.86...
"Jeremy Wallace" <ab**********@A lphaBetCityData works.com> wrote in
news:tI******** ************@sp eakeasy.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(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).


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**********@A lphaBetCityData works.com> wrote in
news:AJ******** ************@sp eakeasy.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********@bwa y.net.invalid> wrote in message
news:Xn******** *************** ***********@24. 168.128.78...
"Jeremy Wallace" <ab**********@A lphaBetCityData works.com> wrote in
news:AJ******** ************@sp eakeasy.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(10 0 , 12+ 1, 1)) - 1
12/31/100

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

Day 0 is the day before day 1.

Clive
"Jeremy Wallace" <ab**********@A lphaBetCityData works.com> wrote in message
news:AJ******** ************@sp eakeasy.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
2282
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; DateDiff("y",-4,DateIn) and get errors Please any assistance would be greatly appreciated. Michael
1
4985
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 blank. I've tried; > >DateDiff("y",-4,DateIn) and get errors > >Please any assistance would be greatly appreciated. >
3
2589
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 inspections occured in 2004. Here's what I have, but it's giving me problems ... what am I doing wrong? Thanks.
18
5928
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. More holidays can be added easily. Also, there is a boolean flag for including or excluding Saturdays or Sundays as part of the work week. The only thing I know of that is missing is that some holidays are observed on a Friday or a Monday if they...
1
15316
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 VB .Net, dragging the mouse over to the statement, VB .NET reports the following "Conversion from 'Date' to "Double' requires calling the 'Date.ToOAdate' method. When I tyoe this method in, the syntax checker undelines
5
3208
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 field is Text (January, February etc). What function is used to convert text month to numerical 1-12? Thanks Jerry
1
1564
by: woooopa | last post by:
Something like this... MAX (DateSerial(!,!,!))
3
2685
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 DateSerial(Year(Date()),Int((Month(Date())-1)/3)*3+1,1) And DateSerial(Year(Date()),Int((Month(Date())-1)/3)*3+4,0),*!,0))) Now, I need to make sure I understand the DateSerials, which I think I do but I'd rather be safe than sorry. For DateSerial(Year(Date()),...
3
5810
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 selecting April returns 4. Also on the form I have a text box where a number is entered and used as the date of the month in the aforementioned combo box. I pull those numbers (month number from the combo and date number from the text box) together...
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10536
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10304
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10063
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.