Urgent!!!! strange! how to CORRECTLY use GetFieldValue(str)?

Hi,

 i have a database file a.mdb, it has a field named "DOB" whose data type is "date/time". now i wnat to get the value of this field for a record:

 COlevariant v1;
 char *s1=(char *)malloc(10*sizeof(char));

 v1=rs.GetFieldValue("DOB");
 s1=(char *)v1.bstrVal;

 however i can not get the value! if i change the data type to "text", then can get it (say 29/10/99).
 any one knows how to get the field value with date/time data type?

 Pls help! thanks a lot!
greenbirdAsked:
Who is Participating?
 
ToronadoConnect With a Mentor Commented:
Hi greenbird,

you can use this:

CString strRet;

if (v1.vt == VT_DATE)
{ strRet = COleDateTime(v1).Format(_T("%m %d %y"));
}

I'm pretty sure it will work.

Regards,
 Toronado
0
 
MDarlingCommented:
try casting to COleDateTime and using
that classes member functions.

regards,
mike.
0
 
Nicolay_ChCommented:
CDaoRecordset* m_UserRecordSet;

//initializing m_UserRecordSet
....
....

//getting date/time
COleDateTime odt;
odt = m_UserRecordSet->GetFieldValue("DOB");

//COleDateTime = more functionality that CTime
0
All Courses

From novice to tech pro — start learning today.