我正在从数据库中读取日期时间ColeDateTime
格式。我想将其转换为CTime
获取日期、月份、年份和时间。
CString repDt; //**this will hold the datetime which i read from Database**
COleDateTime dt;
//**my datetime format is mm/dd/yyyy.**
dt.ParseDateTime(repDt); **//this line of code gives exception**
CTime t(dt.GetYear(), dt.GetMonth(), dt.GetDay(), dt.GetHour(),
dt.GetMinute(), dt.GetSecond());
m_time=t.GetTime();
请给我一些解决方案我该怎么做?
提前致谢。
The CTime
构造函数接受两者SYSTEMTIME
and DBTIMESTAMP
结构,所以这两个都可以工作:
SYSTEMTIME st;
if (dt.GetAsSystemTime(st))
t = CTime(st);
,
DBTIMESTAMP dbts;
if (dt.GetAsDBTIMESTAMP(dbts))
t = CTime(dbts);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)