LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

time/date functions

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.

0 Kudos
Message 1 of 2
(4,530 Views)

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.

 

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 2
(4,520 Views)