Solved

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

Posted on 1998-10-09
6
129 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
Comment Utility
Edited text of question
0
 

Author Comment

by:rgeiman
Comment Utility
Adjusted points to 150
0
 
LVL 6

Expert Comment

by:snoegler
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:rgeiman
Comment Utility
Edited text of question
0
 
LVL 7

Accepted Solution

by:
psdavis earned 150 total points
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
This video discusses moving either the default database or any database to a new volume.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now