KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q57366: DateSerial# Accepts Values Outside Range for Arguments

Article: Q57366
Product(s): See article
Version(s): 7.00 7.10 | 7.00 7.10
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | docerr SR# S891227-47 | mspl13_basic
Last Modified: 8-JAN-1991

Page 425 of the "Microsoft BASIC 7.0: Language Reference" manual (for
7.00 and 7.10) states that the DateSerial# function will generate an
"Illegal function call" if values are specified outside the given
ranges of the following:

   year%  - A year from 1753 to 2078
   month% - A month from 1 to 12
   day%   - A day from 1 to 31

An "Illegal function call" is only generated if the year, month, and
day arguments generate a serial number outside the valid range of
-53,688 to 65,380. The corresponding dates for this range are January
1, 1753, to December 31, 2078.

The README.DOC file provided with Microsoft BASIC Professional
Development System (PDS) Versions 7.00 and 7.10 notes this
documentation error.

This information applies to Microsoft BASIC Professional Development
System (PDS) versions 7.00 and 7.10 for MS-DOS and MS OS/2.

The DateSerial# function can return serial numbers for dates in the
following range, inclusive:

   DATE:     January 1, 1753, to December 31, 2078
   SERIAL#:           -53688 to 65380

The DateSerial# function generates an "Illegal function call" only if
the arguments passed to it generate a serial number outside the range
of -53,688 to 65,380. The following example uses a value outside the
given range for the "month%" argument, but does not generate an
"Illegal function call":

   theDate# = DateSerial#(89, 13, 1)

The serial number returned in the above call actually corresponds to
the date January 1, 1990. A value of 13 logically corresponds to the
month following December. Since December is the last month of a year,
the year value is incremented by 1, and the month value is reset to 1,
which corresponds to January; therefore, the following two calls to
DateSerial# return the same serial number:

   theDate# = DateSerial#(89, 13, 1)
   theDate# = DateSerial#(90,  1, 1)

Negative numbers work in the same way. A value of "-1" for the month
argument refers to the month of November in the previous year. The
following to calls to DateSerial# return the same serial number:

   theDate# = DateSerial#(90, -1, 1)
   theDate# = DateSerial#(89, 11, 1)

The following are example calls to DateSerial# that generate the
"Illegal function call" error message since the resulting serial
number falls outside the valid range:

   theDate# = DateSerial#(2078, 12, 32)  ->  January   1, 2079
   theDate# = DateSerial#(2078, 13,  1)  ->  January   1, 2079
   theDate# = DateSerial#(1753,  0, 31)  ->  December 31, 1752

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.