XL: DateValue Function Doesn't Accept Date Literals

Last reviewed: February 2, 1998
Article ID: Q116117

The information in this article applies to:
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for Windows 95, versions 7.0, 7.0a
  • Microsoft Excel for the Macintosh, versions 5.0, 5.0a

SYMPTOMS

In the versions of Microsoft Excel listed above, the Visual Basic DateValue function does not accept a date literal (for example, #8/12/71#) as an argument.

NOTE: In Microsoft Excel 97 for Windows and Microsoft Excel 98 Macintosh Edition, the DateValue function DOES accept a date literal.

MORE INFORMATION

In Visual Basic Help, the following information is contained in the entry for the DateValue function:

   The 'date' named argument is normally a string expression
   representing a date from January 1, 100 through December 31, 9999.
   However, 'date' can also be any expression that can represent a
   date, a time, or both a date and time, in that range.

The last sentence of this entry is only partially correct. The DateValue function does not accept a date literal in the #<date># format. If you attempt to use a date literal in the DateValue function, you receive the error message

   Type mismatch

and your subroutine does not run.

The DateValue function accepts only strings that represent dates ("July 4, 1776", "1-Jan-95", "9/1/94", and so on) or other functions that return the same type of information [the DATE() function, the NOW() function, and so on].


Additional query words: 5.00 5.00a 5.00c 7.00 7.00a XL7 XL5
Version : WINDOWS:5.0,7.0; MACINTOSH:5.0,5.0a
Platform : MACINTOSH WINDOWS
Issue type : kbdocerr


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.

Last reviewed: February 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.