Link to home
Start Free TrialLog in
Avatar of BlueAndWhite
BlueAndWhite

asked on

DateAdd

is there a function that add part of date specific value, like DateAdd of Basic ?
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BlueAndWhite
BlueAndWhite

ASKER

in VC
Thanks
If you're using MFC and CTime or COleDateTime, you can add or subtract based on the CTimeSpan or COleDateTimeSpan classes:

CTime now = CTime::GetCurrentTime();
now += CTimeSpan(0, 1, 0, 0); // Add 0 days, 1 hour, 0 minutes, and 0 seconds

If you're using the basic time_t, you can always add the number of seconds:
time_t now = time(NULL);
now += 2 * 24 * 60 * 60; // Add 2 days in seconds

Good luck.