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?
carldeanConnect With a Mentor Commented:
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!!!)
eugene007Author Commented:
Edited text of question.
All Courses

From novice to tech pro — start learning today.