Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CtimeSpan, more accurate way?

Status
Not open for further replies.

Essendry

IS-IT--Management
Nov 13, 2002
4
0
0
GB
I need to use CTimespan to depict the difference between two CTime objects, and use this to calculate an age. Is there a more accurate way of giving a persons age other than dividing the CTimespan object age by 365 (not taking into account leap years)to get the total years? - Only using a CTimespan member function.

#include <afx.h>

void main()
{
int currentage,days;

CTime dob(1981, 11, 17, 0, 0, 0);
CTime now = CTime::GetCurrentTime();
CTimeSpan age = now - dob;
days = age.GetDays();
currentage = days/365;

printf(&quot;Age = %d\n&quot;,currentage);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top