Microsoft KB Archive/117316

{|
 * width="100%"|

ODBCDATE Sample Illustrates Working with Database Dates

 * }

Q117316

-

The information in this article applies to:


 * The Microsoft Foundation Classes (MFC), used with:
 * Microsoft Visual C++, versions 1.5, 1.51, 1.52

-

SUMMARY
The ODBCDATE sample illustrates working with dates using the Microsoft Foundation Database Classes. The sample consists of a simple application which has the ability to add, delete, edit, and query for records containing a first name, last name, and birthday date field.

NOTE: With the release of Microsoft Visual C++ 2.0 (and later versions) the TIMESTAMP_STRUCT used in this sample was incorporated into the MFC architecture.

MORE INFORMATION
The following files are available for download from the Microsoft Download Center:

Odbcdate.exe

For additional information about how to download Microsoft Support files, click the article number below to view the article in the Microsoft Knowledge Base:

"Q119591 How to Obtain Microsoft Support Files from Online Services" Microsoft used the most current virus detection software available on the date of posting to scan this file for viruses. Once posted, the file is housed on secure servers that prevent any unauthorized changes to the file.

ODBCDATE.EXE contains subdirectories, so after you download it, place it in an empty directory, and use -d option when you run it to extract the sample files. Type the following at the MS-DOS command line:

"ODBCDATE -d" See the README.TXT file included with the sample for more information about how to run it.

Some of the techniques illustrated by the ODBCDATE sample include:


 * Working with dates previous to 1970 and after 2038 by defining a version of the RFX_Date function which works with a TIMESTAMP_STRUCT object instead of a CTime object.
 * Dynamically building an SQL Query statement based upon information provided by the user at run-time.
 * Querying for records using a date range.

ODBCDATE is based on an AppWizard generated application. Files included with the sample which are directly related to working with dates are:

ADDDLG.CPP -

Implements a dialog box which allows the user to add a records to the database.

DELDLG.CPP -

Implements a dialog box which allows the user to delete records from the database.

EDITDLG.CPP -

Implements a dialog box which allows the user to edit existing records in the database.

QUERYDLG.CPP -

Implements a dialog box which allows the user to query for records in the database using any combination of first name, last name, starting date, and ending date.

RFXDATE.CPP -

Implements the RFX_Date function which works with a TIMESTAMP_STRUCT to get around the CTime limit of not being able to represent dates prior to 1970 and after 2038. Additional query words: kbinf rfx_date timestamp ctime

Keywords : kbfile kbsample kb16bitonly kbDatabase kbMFC kbODBC kbVC

Issue type :

Technology : kbAudDeveloper kbMFC