?
Solved

CTime and CString question

Posted on 2003-03-05
6
Medium Priority
?
896 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Simple Linear Regression
Suggested Courses
Course of the Month7 days, 20 hours left to enroll

765 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