?
Solved

CTime and CString question

Posted on 2003-03-05
6
Medium Priority
?
899 Views
Last Modified: 2007-12-19
Hi All,
I am working with time and I am converting these times to CStrings. I am looking for a way to test 2 CStrings 1 created from CTime t;
t=CTime::GetCurrentTime();
CString EndTime;
EndTime=t.Format("%A, %B %d, %Y"); and the other entered
by a user in an edit box with a CString StartTime;.
How can I test these 2 strings to see how many days have passed?

           Thank you very much,
              Arnold.
0
Comment
Question by:arnold100
  • 3
  • 3
6 Comments
 

Expert Comment

by:mimounette
ID: 8075757
You can use the CTimeSpan class.

COleDateTime endtime;

COleDateTime startTime = COleDateTime::GetCurrentTime();
endtime.ParseDateTime(strEndTime);

CTimeSpan elapsedTime = endTime - startTime;

Hope it helps
0
 

Expert Comment

by:mimounette
ID: 8075761
Correction... Sorry for the tipo

You can use the COleTimeSpan class.

COleDateTime endtime;

COleDateTime startTime = COleDateTime::GetCurrentTime();
endtime.ParseDateTime(strEndTime);

COleTimeSpan elapsedTime = endTime - startTime;

Hope it helps
0
 

Author Comment

by:arnold100
ID: 8105667
Hi,
I get errors when I try to use COleDateTime. What header or lib file do I need to use with COleDateTime?

  Thanks,
  Arnold.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Accepted Solution

by:
mimounette earned 400 total points
ID: 8105708
#include <afxdisp.h>
0
 

Author Comment

by:arnold100
ID: 8106021
Hi mimounette,
COleDateTime was just what I have been looking for.
I was working with GetDay, GetMonth and GetYear but
it was more work and adding size to my program. I want to keep the size as small as possible and COleDateTime has helped. I thank you very very much.

       Sincerely yours,
       Arnold.
0
 

Author Comment

by:arnold100
ID: 8106036
Excellent says it all.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
No other job is as rewarding and demanding as building an iPhone app is. It is not really in the hands of the developer for the success of an iPhone app. Many factors operate jointly for every iOS application's success in the market.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question