The "RFX_Date" function returns a value of "December 30, 1899" when you run the function on a date/time data type field in a Visual C++ .NET Framework application

Article translations Article translations
Article ID: 937464 - View products that this article applies to.
Expand all | Collapse all

SYMPTOMS

Consider the following scenario. In a Microsoft Visual C++ .NET Framework application, you call the RFX_Date function on a date/time data type field. The field is stored as having a short date/time format in a Microsoft Office Access database. In this scenario, the function returns a value of "December 30, 1899." Additionally, you receive an assertion failure message.

CAUSE

This issue occurs because the date value "December 30, 1899" is out of the range of CTime object dates.

Access stores date/time data type fields as floating-point numbers. The date is represented in the decimal part, and the time is represented in the fractional part. The ranges of date/time data type values in Access are as follows:
  • The date range is from -647,434 (January 1, A.D. 100) to 2,958,465 (December 31, A.D. 9999).
  • The time range is from 0 (00:00:00) to .99999 (23:59:59).
The range of CTime object dates is from 1/1/1970 12:00:00 A.M. to 12/31/3000 11:59:59 P.M. When you insert only the hour and do not include a specific date in an Access database, 0 (zero) is inserted in the date/time data type field. (This behavior is by design in Access.) The fractional part is interpreted as December 30, 1899.

WORKAROUND

To work around this issue, use one of the following methods:
  • Use the TIMESTAMP_STRUCT data type and the appropriate RFX_Date function to load hours.
  • Use the CTime object. However, make sure that records of the database contain only valid values for the CTime object.
  • In the database, use the General Date date/time data type instead of the Short time date/time data type.

REFERENCES

For more information about the RFX_Date function, visit the following Microsoft Developer Network (MSDN) Web site:
http://msdn2.microsoft.com/zh-cn/library/9tzyb0fw(vs.80).aspx
For more information about this function, click the following article number to view the article in the Microsoft Knowledge Base:
114961 RFX_Date function for TIMESTAMP_STRUCT

Properties

Article ID: 937464 - Last Review: August 16, 2007 - Revision: 1.0
APPLIES TO
  • Microsoft Visual Studio 2005 Standard Edition
  • Microsoft Visual Studio 2005 Professional Edition
  • Microsoft Visual Studio 2005 Express Edition
Keywords: 
kbtshoot kbprb KB937464

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com