Solved

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

Posted on 1998-10-09
6
131 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
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 49
How to determine file rename from EventLog ? 2 49
Hibernate methods 2 72
Window placement 17 83
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.

803 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