Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm fighting a few days with COleDateTime in MFC. I have CTime with correct values. Correct years, days, months, hours, minutes and seconds. I tried a few ways to convert CTime to COleDateTime:

-1.I put
C++
CTime
data to constructor of
C++
COleDateTime


C++
COleDateTime(int nYear,int nMonth,int nDay, int nHour, int nMin,int nSec )
;
-2. I formatted
C++
CTime
to
C++
time.Format("%m/%d/%y %H:%M:%S")
;

and passed to
C++
ParseDateTime
of
C++
COleDateTime
.

-3. Also I tried to use
C++
SetDateTime
of
C++
COleDateTime


After that I'm getting incorrect values of minutes 1-2 min. more or less. I have never seen it before and I couldn't find nothing in internet.Everybody says abot loss precision but this a second, not a minute. Please advice something for me! Thank you
Posted

1 solution

Why don't you use constructor
VB
COleDateTime(
   const SYSTEMTIME& systimeSrc
)

and method
C#
bool CTime::GetAsSystemTime(
   SYSTEMTIME& st
)
 
Share this answer
 
Comments
thomas_wingfield 21-May-13 7:38am    
but I have data in CTime and I have to convert CTime to COleDateTime
but thanks I will try it right now

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900