Solved

How can I read in a date from a database???

Posted on 1998-10-09
6
134 Views
Last Modified: 2013-11-20
I can read in fields of all types (CString, int, etc) in a database, but I cannot get the dates (AppWiz defined the date as CTime in the CRecordset derived class) to work properly.  Anyone have any suggestions please??  BTW, I'm using Access 97 and Visual C++ 6.0
0
Comment
Question by:rgeiman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Author Comment

by:rgeiman
ID: 1323148
Edited text of question
0
 

Author Comment

by:rgeiman
ID: 1323149
Adjusted points to 150
0
 
LVL 6

Expert Comment

by:snoegler
ID: 1323150
Just guessing ... Try changing the type to COleDateTime ( i think Access uses the OLE DATE
type, which must be mapped to COleDateTime instead of CTime, but i am not sure).

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rgeiman
ID: 1323151
Edited text of question
0
 
LVL 7

Accepted Solution

by:
psdavis earned 150 total points
ID: 1323152
You're right snoegler!  COleDateTime is almost the only way to use dates with Access.  Here's a code snipplet that set's the time in my dao table to the current time.

pSearchJobsSet->Edit( );
pSearchJobsSet->m_Start_Time = COleDateTime::GetCurrentTime( );
pSearchJobsSet->Update( );

The opposite *should* be absolutely true.  Here's a pseudo-code to read the same date...

COleDateTime dtStartTime;
dtStartTime = pSearchJobsSet->m_Start_Time;

Phillip
0
 

Expert Comment

by:umarama
ID: 1323153
It's O.K. to use CTime. I have used it with CRecordsets.
CTime gives problems (usually invalid memory reference) when the object is not initialized and the database defaults to one (say to Now()). Try initializing your CTime object to either 0 or CTime::GetCurrentTime(). Basically, initialize it to some value !


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adapt this command to show who installed 29 114
VBA "SendKeys" Syntax for Multiple Keystrokes 7 133
EvenOdd challenge 10 160
Problem to event 3 123
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question