rian
asked on
Converting C++ Date type to SQL DateTIme
Sorry to bother. But I need to find out a way to convert a C++
Date type to SQL DATETIME type in C++. I'm using ADO to add
information to a table.
I'm using the following code to add information to a field
m_pRs->Fields->GetItem("BU NIT")->Put Value(_bst r_t(m_BUNI T));
m_BUNIT is a CSTRING and BUNIT is a Char type.
But I am having a tough time adding values to a DT type.
Appreciate your help.
Date type to SQL DATETIME type in C++. I'm using ADO to add
information to a table.
I'm using the following code to add information to a field
m_pRs->Fields->GetItem("BU
m_BUNIT is a CSTRING and BUNIT is a Char type.
But I am having a tough time adding values to a DT type.
Appreciate your help.
ASKER
I have use CDateTime, COleDateTime and well as DATE structure. I have also tried to use CString with a Format statement to Float. My problem is I do not know how to convert the above C++ structures to SQL DateTime Structure.
There is no standard SQL datetime structure (it varies depedning on DB).
However, there is a standard variant datetime type - which you need to convert to.
Use a COleVariant (or _variant_t) - this has conversion functions galore.
However, there is a standard variant datetime type - which you need to convert to.
Use a COleVariant (or _variant_t) - this has conversion functions galore.
Do u want to convert into
ODBC Date time Struct.
ODBC Date time Struct.
ASKER
As long as the ODBC Date Time Struct is similar to the Microsoft
SQL Server 7.0 Date time structure.
SQL Server 7.0 Date time structure.
C++ has no date structure. What are you cxonverting from? SQL has TIMESTAMP. Is that the destination type?
ASKER
Sure does. CDateTime, Date, COleDateTime are all DateTime structures. SQL has a DATETIME structure.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks again.
By "DateTime" I assume you mean adDBTimeStamp?