Link to home
Start Free TrialLog in
Avatar of rgeiman
rgeiman

asked on

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
Avatar of rgeiman
rgeiman

ASKER

Edited text of question
Avatar of rgeiman

ASKER

Adjusted points to 150
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).

Avatar of rgeiman

ASKER

Edited text of question
ASKER CERTIFIED SOLUTION
Avatar of psdavis
psdavis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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 !