LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How Can I Convert a DATE type data to ansi data type: time_t

When I use the ActiveX: Date and time picker, I met a problem: first I use the function: CA_VariantGetDate to get a DATE type data, but how can I convert it to a Ansi "time_t" type?
thank you!
0 Kudos
Message 1 of 3
(3,356 Views)
If you haven't already done so you'll need to install the SDK that came with CVI and then this should help you out...

Best wishes,
Steve

Converts the variant representation of time-to-system time values.

INT VariantTimeToSystemTime(
double vtime,
LPSYSTEMTIME lpSystemTime
);

Parameters
vtime
The variant time that will be converted.
lpSystemTime
Pointer to the location where the converted time will be stored.
Return Value
The return value obtained from the returned INT is one of the following.

Value Meaning
TRUE Success.
FALSE Failure.

Comments
A variant time is stored as an 8-byte real value (double), representing a date between January 1, 100 and December 31, 9999, inclusive. The value 2.0 represe
nts January 1, 1900; 3.0 represents January 2, 1900, and so on. Adding 1 to the value increments the date by a day. The fractional part of the value represents the time of day. Therefore, 2.5 represents noon on January 1, 1900; 3.25 represents 6:00 A.M. on January 2, 1900, and so on. Negative numbers represent the dates prior to December 30, 1899.

Using the SYSTEMTIME structure is useful because:

It spans all time/date periods. MS-DOS date/time is limited to representing only those dates between 1/1/1980 and 12/31/2107.
The date/time elements are all easily accessible without needing to do any bit decoding.
The National Language Support data and time formatting functions GetDateFormat and GetTimeFormat take a SYSTEMTIME value as input.
It is the default Win32 time and date data format supported by Windows NT and Windows 95.
Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 OSR2 or later.
Windows CE: Requires vers
ion 2.0 or later.
Header: Declared in oleauto.h.
Library: Use oleaut32.lib.

Built on Monday, August 16, 1999
Message 2 of 3
(3,356 Views)
Thank you very much, joe
0 Kudos
Message 3 of 3
(3,356 Views)