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

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
rgeimanAsked:
Who is Participating?
 
psdavisConnect With a Mentor Commented:
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
 
rgeimanAuthor Commented:
Edited text of question
0
 
rgeimanAuthor Commented:
Adjusted points to 150
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
snoeglerCommented:
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
 
rgeimanAuthor Commented:
Edited text of question
0
 
umaramaCommented:
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
All Courses

From novice to tech pro — start learning today.