Click here to Skip to main content
15,887,821 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have read until my head started spinning. I can not figure out how COleDateTime works with dialogs. I can add the current date and time to my dialog, but I want to know how to manipulate the date/time (get the current date/time and set it to another date/time and then display it). How do I proceed or where can I learn how to do this?
Posted
Comments
DrBones69 5-Jul-11 21:58pm    
If I have m_dtDate.GetDay() what is the proper way(format) to display m_dtDate in an edit control(m_wndDate)???

I don't think this is the only or even necessarily the best way to encapsulate a date, but it's really straightforward from what I see.

http://msdn.microsoft.com/en-US/library/by5d3kb1(v=VS.80).aspx[^]

GetCurrentTime gets the current time. SetDateTime sets it. Operator +, -, +=, -=, means you can add them together. The Format method lets you build a formatted version for display.
 
Share this answer
 
Comments
DrBones69 5-Jul-11 22:02pm    
I read this last night, but I was so tired I couldn't wrap my brain around it. It makes a little more sinse today. What format do I need to display the result of (m_dtDate.GetDate()) in any edit box control???
I created a variable m_oleMyDate of type COleDateTime in my ...View.h file and then initialized it to (COleDateTime::GetCurrentTime()) in my View .cpp file.

Next, I created three variables of type int (nYear, nMonth, nDay) and then set the variables with the current month day and year as follows:

nYear = m_oleMyDate.GetYear();
nMonth = m_oleMyDate.GetMonth();
nDay = m_oleMyDate.GetDay();

I then created a function to manipulate the date for any purpose.

Finally, I used m_oleMyDate.SetDate(nYear, nMonth, nDay) to display my new date.

Thanks for the help
 
Share this answer
 

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