从数据库里取时间,格式怎么写呀?tt=pRst->GetCollect(_variant_t("大时间")).bstrVal;,我这样写取不出来时间格式的数据。是不是有什么特殊的格式啊? CString strSQL;
strSQL.Format(_T("select * from Table_time where 编号=%d"),1); try{
pRst->Open(_variant_t(strSQL), _variant_t((IDispatch*)pConn,true),adOpenStatic, adLockOptimistic, adCmdText);
while (!pRst->rsEOF)
{
unsigned short * tt;
tt=pRst->GetCollect(_variant_t("大时间")).bstrVal;
CString t;
printf(t,"t=%s",tt);
MessageBox(t);
}
}
strSQL.Format(_T("select * from Table_time where 编号=%d"),1); try{
pRst->Open(_variant_t(strSQL), _variant_t((IDispatch*)pConn,true),adOpenStatic, adLockOptimistic, adCmdText);
while (!pRst->rsEOF)
{
unsigned short * tt;
tt=pRst->GetCollect(_variant_t("大时间")).bstrVal;
CString t;
printf(t,"t=%s",tt);
MessageBox(t);
}
}
CTime 。::DatetimeToCTime(_variant_t time)
{
COleDateTime dt(time);
SYSTEMTIME systime;
VariantTimeToSystemTime(dt,&systime);
CTime tm(systime);
return tm;
}
_variant_t vtVal;
vtVal = pRst->GetCollect(_variant_t("大时间"));
if (vtVal.vt == VT_DATE)
{
COleDateTime dt(vtVal);
}