Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 241893 - Last Review: January 25, 2007 - Revision: 1.3
PRB: VarDateFromStr Does Not Consider Date Formats for Specific Locales
This article was previously published under Q241893
The
VarDateFromStr function may return without an error when a seemingly invalid date is passed. Furthermore, the
VarDateFromStr function may return without error, regardless of what the locale is set to.
In
VarDateFromStr, the code does not strictly check the string passed against the date format of the default system locale, default user locale, or the locale passed to the function. The function returns without error if the passed string is valid in any of the following date formats:
- DD-MM-YYYY
- MM-DD-YYYY
- YYYY-MM-DD
If you need to verify that the date is valid based on the specific date format for a locale, do not depend on the
VarDateFromStr function. This implies that any code relying on the MFC function
COleDateTime::ParseDateTime to do strict checking should be changed also because this MFC function uses
VarDateFromStr internally. Microsoft recommends that you check the string first in your code before calling
VarDateFromStr or
COleDateTime::ParseDateTime to make sure it is a correct date for the date format of the locale.
This behavior is by design.
When calling
VarDateFromStr, even under the English (United States) locale, you can pass a date such as "29-2-01". This is evaluated to Jan 2, 2029, and
VarDateFromStr will not return an error.
APPLIES TO
- Microsoft Windows NT Server 4.0 Standard Edition
- Microsoft Windows NT Workstation 4.0 Developer Edition
- Microsoft Windows 98 Standard Edition
- Microsoft Windows 95
- Microsoft Platform Software Development Kit-January 2000 Edition
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate