I have a class that wraps CRecordset to read/write values to an SQL table using ODBC.
I recently discovered however that when dealing with datetime fields the milliseconds were being lost.
So I looked up RFX_Date and did some googling to find that the version we had used was the CTime version, which has no milliseconds.
OK, so I changed my class from using CTimes to TIMESTAMP_STRUCT.
I ran my code and stepped through and could now see the milliseconds being valid using the following code where m_tDate is the TIMESTAMP_STRUCT which is used in the RFX_Date.
The problem is it isn't actually working! The value in the table is still truncated to the nearest second. I have checked using SQL Server 2005 management studio.
I have also tried using a COleDateTime but also debugs fine but doesn't actually put the milliseconds into the table datetime field.
What am I missing?
// From the header
// From the source
m_nDefaultType = dynaset;
m_Date.year = sysTime.wYear;
m_Date.month = sysTime.wMonth;
m_Date.day = sysTime.wDay;
m_Date.hour = sysTime.wHour;
m_Date.minute = sysTime.wMinute;
m_Date.second = sysTime.wSecond;
m_Date.fraction = sysTime.wMilliseconds;
void CProductHistorySet::DoFieldExchange(CFieldExchange* pFX)
RFX_Date(pFX, _T("[Datedb]"), m_Date);