LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I display the time in milliseconds, like 12:34:56.789?

TimeStr() is close with 12:34:56, but there is no fractional part.
0 Kudos
Message 1 of 8
(4,533 Views)
Check out FormatDateTimeString (along with GetCurrentDateTime), with something like "%H:%M:%S.%2f" for your format string.

Mert A.
National Instruments
0 Kudos
Message 2 of 8
(4,530 Views)
My CVI, version 7.1, doesn't have either of those functions. I even searched through all the .h files for both of those function names.
 
Where can I get those functions?
0 Kudos
Message 3 of 8
(4,502 Views)
I'm sorry, those functions were added in version 8.0.  Do you really need the string to reflect the time of day?  If you are just concerned with profiling, you could always use clock()/CLOCKS_PER_SEC to get the number of seconds (with sub-second precision) your program has run.  Other than that, I'm not aware of a time utility that will give you sub-second precision.

Sorry for the confusion.

Mert A.
National Instruments
0 Kudos
Message 4 of 8
(4,492 Views)

do following ...

1. TOP of your file//////////////////////////////

#include "windows.h"
#undef GetSystemTime
 

2. In your function///////////////////////////////

 SYSTEMTIME sdktime; 
   int mon, day, year;
  int hour, min, sec, msec;

 GetLocalTime (&sdktime);
 
 mon = sdktime.wMonth;
 day = sdktime.wDay;
 year = sdktime.wYear;
 hour = sdktime.wHour;
 min = sdktime.wMinute;
 sec = sdktime.wSecond;
 msec = sdktime.wMilliseconds;

 

Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
Message 5 of 8
(4,488 Views)
The ansi strftime() function in cvi can also handle time to string conversion.
But unfortunately does not seem to have an output format for milliseconds.

Message Edited by mvr on 07-11-2006 04:15 PM

0 Kudos
Message 6 of 8
(4,478 Views)
I had to include "windows.h" before some other includes, but that worked great. Thanks.
0 Kudos
Message 7 of 8
(4,473 Views)
If you are going to use windows.h in CVI, it is good practice to always make it the first header file you include. There may be an exception or two to that but hopefully the author of the files was kind enough to put a preprocessor warning in there to tell you the proper order.
Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 8 of 8
(4,468 Views)