TIME SPAN

I have program written in VC++ 6.0 require to calculate total days which is 30 and I am stuck at following code and dont know how to get 30 days to 29 to 28 and code is as below: // How to find date diff



COleDateTime timeStart, timeEnd;
timeStart = COleDateTime::GetCurrentTime();
// ... perform time-consuming task
timeEnd = COleDateTime::GetCurrentTime();
COleDateTimeSpan spanElapsed = timeEnd <= timeStart;



CString strMessage; strMessage.Format("VICTOR was not activated within 30 days of installation and is currently not functional. \n" "To activate please call Avtron Field Service at XXX-XXX-XXXX ext 1214.\n" "The 30 days trial period starts on the day you installed VICTOR.\n" "You have %d" " days left to renew ADDapt Software.", (int)spanElapsed.GetTotalDays());

AfxMessageBox(strMessage);



COleDateTime timeStart, timeEnd;
timeStart = COleDateTime::GetCurrentTime();
// ... perform time-consuming task
timeEnd = COleDateTime::GetCurrentTime();
COleDateTimeSpan spanElapsed = timeEnd <= timeStart;



CString strMessage; strMessage.Format("VICTOR was not activated within 30 days of installation and is currently not functional. \n" "To activate please call Avtron Field Service at XXX-XXX-XXXX ext 1214.\n" "The 30 days trial period starts on the day you installed VICTOR.\n" "You have %d" " days left to renew ADDapt Software.", (int)spanElapsed.GetTotalDays());

AfxMessageBox(strMessage);
COleDateTime dtCurrent;
dtCurrent = COleDateTime(2011,9,25,0,0,0);
COleDateTimeSpan dtDiff = COleDateTime::GetCurrentTime() - dtCurrent;*/
CString strMessage;
strMessage.Format("VICTOR was not activated within 30 days of installation and is currently not functional. \n"
"To activate please call Avtron Field Service at 216-642-1230 ext 1214.\n"
"The 30 days trial period starts on the day you installed VICTOR.\n"
"You have %d" " days left to renew VICTOR Software.", (int)spanElapsed.GetTotalDays());
AfxMessageBox(strMessage);


***************** 2nd way is as follow*************

COleDateTime timeStart, timeEnd;
timeStart = COleDateTime::GetCurrentTime();
// ... perform time-consuming task
timeEnd = COleDateTime::GetCurrentTime();
COleDateTimeSpan spanElapsed = timeEnd <= timeStart;
Last edited on
I am trying to get DateDifference from TimeStart to timeEnd in VC++ 6.0 with MFC with WIN application
First thing I need to do is : to register software to registry and it will calculate or display date product install and from day install to day end has 30 days which reduce every day will indicate in %d in code. when software reaches 3 days it will prompt to register product with product code in security tab. and code I have been working on is as follow:

COleDateTime timeStart;
COleDateTimeSpan timePassed;
int daysLeft = 0;
timeStart = COleDateTime::GetCurrentTime();
// Date and time of the Installation.
timePassed = COleDateTime::GetCurrentTime( ) - timeStart;
daysLeft = 30 - static_cast< int >( timePassed.GetTotalDays( ) );
CString strMessage; if( daysLeft > 0 )
{
strMessage.Format( "ADDapt was not activated within 30 days of \n"
"installation and is currently not functional.\n"
"To activate please call Avtron Field Service at 000-000-1230 \n"
"You have %d days left to renew ADDapt Software.", daysLeft );

}
else
{
strMessage.Format( _T("ADDapt is operation undera license, \n")
_T("You have %d " " days to activate ADDapt with valid license, \n")
_T("To activate, Please call l Avtron Field Service at 000-000-1230."), daysLeft );
}
AfxMessageBox( strMessage, MB_OKCANCEL);
Last edited on
Topic archived. No new replies allowed.