SAMPLE: ODBCDATE Sample Illustrates Working with Database Dates

Last reviewed: July 18, 1997
Article ID: Q117316
1.50 1.51 1.52 WINDOWS kbprg kbfile

The information in this article applies to:

  • The Microsoft Foundation Classes (MFC), included with: - Microsoft Visual C++ for Windows, version 1.5, 1.51, and 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.

To obtain the ODBCDATE sample, download ODBCDATE.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:

  • Microsoft Download Service (MSDL)

          Dial (206) 936-6735 to connect to MSDL
          Download ODBCDATE.EXE (size: 81640 bytes) 
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the SOFTLIB\MSLFILES directory
          Get ODBCDATE.EXE (size: 81640 bytes) 
    

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.

MORE INFORMATION

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 reference words: 1.50 1.51 1.52 2.50 2.51 2.52 kbinf rfx_date
timestamp ctime
KBCategory: kbprg kbfile
KBSubcategory: MfcDatabase
Keywords : kb16bitonly MfcDatabase kbfile kbprg
Technology : kbMfc
Version : 1.50 1.51 1.52
Platform : WINDOWS


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: July 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.