11-04-2014 07:07 AM
what functions exist in CVI or ansi C to perfrom date arithmetic? I would like to add 50 days to the current date. I do not need the time, just the day/month/year.
11-04-2014 08:27 AM
ANSI C time functions give a number of seconds since a given date (Jan 1, 1900 UTC), so adding days to the time is simply a matter of adding 86400 * number of days.
As an example, these lines can be pasted and executed into the Interactive Execution window:
#include <ansi_c.h> static time_t dh; #include <utility.h> time (&dh); DebugPrintf ("Today is %s", ctime (&dh)); dh += 86400 * 50; DebugPrintf ("New date: %s", ctime (&dh));
CVI offers also some proprietary functions to handle date and time: take a look to Date/Time >> CVI time class in the utility library. AddToCVIAbsoluteTime can be a good function for you to consider.