现在有一个CString 类型 ctsr = "20050302184623" 为日期
我本想转换为__int64
__int64 i = _ttoi64((LPCTSTR)cstr);
但是老师说不行,因为日期比较是可以实现的,说了一个函数
VarDateFromStr
请问具体如何实现以及比较
我本想转换为__int64
__int64 i = _ttoi64((LPCTSTR)cstr);
但是老师说不行,因为日期比较是可以实现的,说了一个函数
VarDateFromStr
请问具体如何实现以及比较
OLECHAR * strIn,
LCID lcid,
unsigned long dwFlags,
DATE * pdateOut
);
Parameters
strIn
[in] The value to coerce.
lcid
[in] For conversions from string and VT_DISPATCH input, the LCID to use for the conversion. For a list of LCIDs, see Supporting Multiple National Languages and Exposing ActiveX Objects.
dwFlags
[in] One or more of the following flags: Flag Description
LOCALE_NOUSEROVERRIDE Uses the system default locale settings, rather than custom locale settings.
VAR_CALENDAR_HJRI If set then the Hijri calendar is used. Otherwise the calendar sent in the control panel is used.
VAR_DATEVALUEONLY Omits the time portion of a VT_DATE and returns only the date. Applies to conversions to or from dates. Not used for VariantChangeType and VariantChangeTypeEx.
VAR_TIMEVALUEONLY Omits the date portion of a VT_DATE and returns only the time. Applies to conversions to or from dates. Not used for VariantChangeType and VariantChangeTypeEx. pdateOut
[out] Points to the coerced value. For input dates with the year between 194707 and 206607 (inclusive), VarDateFromStr will truncate the output value and generate a valid date, with the year in the range from 0 through 9999. In this case, the function returns S_OK.
另外你们老师绝对有问题,简单的问题搞复杂,何必呢?????
一个某日(也忘了)到当前的秒数
所以__int64存日期只有200多年,具体可参考SQL标准,MSSQL帮助中也有.你们老师是对的,不过明显是态度不好.^_^PS:幸亏DATETIME取值标准是美国人定的,200年就够用了,要是让中国人来定没准要用到__int512.哈哈
http://sourceoflife.blogchina.com/1847677.html