COMVariantType的Date类型
生活随笔
收集整理的這篇文章主要介紹了
COMVariantType的Date类型
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
剛跟一個同事討論通過CCADOConnection讀取外部數(shù)據(jù)庫數(shù)據(jù)的問題,如果讀取的數(shù)據(jù)是DateTime類型,只能得到Date部分,Time部分被忽略了。
查看類CCADOField的value方法找到問題所在,下面是MSDN上關于COMVariant的Date方法的Remark:
A
它特意提到如果類型是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());
查看類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());
轉(zhuǎn)載于:https://www.cnblogs.com/Farseer1215/archive/2009/09/02/1559185.html
總結
以上是生活随笔為你收集整理的COMVariantType的Date类型的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 黄泥猪脚做法
- 下一篇: 80寸电视机机挂墙尺寸?