ODBC - CRecordset - CRecordview

Environment : Visual C++ and MS Access

Interface : ODBC

Views : CRecordview

Question :

I have two dates:

1) 12/09/1999
2) 12/15/1999

How do i find the difference between this two dates. What function is being used to find the difference between this two dates.

Note : I want to know the difference interms of days. The date difference for the above example will be 7 days. The date will be placed in a variable because i am getting those valus from an edit control in my record view.


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

eugene007Author Commented:
Edited text of question.
If you stuff your dates into CTime objects then you can subtract one from the other.  The result is a CTimeSpan object on which you can query the number of complete days.


CTime date1(1999, 12, 9, 0, 0, 0);
CTime date2(1999, 12, 15, 0, 0, 0);

CTimeSpan diff = date2 - date1;
long numDaysDiff = diff.GetDays();

Hope this helps.

(P.S. You don't really deserve an answer for a measily 7 points!!!)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.