COMVariantType的Date类型

刚跟一个同事讨论通过CCADOConnection读取外部数据库数据的问题,如果读取的数据是DateTime类型,只能得到Date部分,Time部分被忽略了。
查看类CCADOField的value方法找到问题所在,下面是MSDN上关于COMVariant的Date方法的Remark:
A COMVariant object has a date and time data type if its data type is set to COMVariantType::VT_DATE. When you set the value of the object, you must set the time part of the value in addition to the date. To set the time part of the value, use the time property.
它特意提到如果类型是COMVariantType::VT_DATE,那么这个COMVariant对象会有Date和Time两部分组成,分别通过Date和Time方法得到,而在CCADOField的value方法中,关于日期的类型:
case COMVariantType::VT_DATE:
            
return value.date();
它显然把time给忽略掉了,要想获取time需要改造一下这部分。
case COMVariantType::VT_DATE:
            
return DateTimeUtil::newDateTime(value.date(),value.time());
原文地址:https://www.cnblogs.com/Farseer1215/p/1559185.html