We help IT Professionals succeed at work.

CTime     MFC   MS Access

ghimireniraj asked

I am using a CRecordSet  class in which there is a
RFX_Date function

I am connecting to an Access database and one of the field is date time   (general Long in access)

Now when I retrive the date

which is

m_pSet->m_time.GetHour()   always gives me 19
m_pSet->m_time.GetMinute()   always gives me 0

I am using ODBC

But if I create the same table in SQL server and use the same program just changing DSN I get the correct hour and mins in the database field.

Anybody has an idea what problem with access I might be having?

To summarise :

If I want to exchange the CTime var in   RFX_date(..)
with a time field in ACCESS what is the correct access time/date datatype should I be using or are they not compatible?

Running out of points so please bear with 50 points although this deserves more points.


Watch Question

try using a TIMESTAMP_STRUCT instead of CTime
(If you're using MS ODBC 1.0 fo Access, KB Q119487 might apply)

Documentaiton is somewhat scrace, so I repeat it here:

     SQLSMALLINT year;
     SQLUSMALLINT month;
     SQLUSMALLINT minute;
     SQLUSMALLINT second;
     SQLUINTEGER fraction;[b]

Other option: Years before 1753 can't be stored, no workaround possible



Thank You PeterChen.

The prob was in the incapability of CTime to handle invalid date and since I could never enter a correct date in that format in my DB.


Explore More ContentExplore courses, solutions, and other research materials related to this topic.