Fractional part of second in FormatDateTime()


Gammatech

Recommended Posts

I have DAQFactory time that gives precision well beyond the second. To read this as a human I display FormatDateTime("%a %d %b %H:%M:%S.",MyTime) but this only gives a string down to the whole second. How can I get the fractional part of the second in a table similar to the table view of a channel. There doesn't seem to be the FRAC() function and MyTime - Floor(MyTime) gives me 0.xxx which means string manipulation to get rid of the leading zero. What have I missed?

Link to comment
Share on other sites

There is no Frac() function because you achieve the same thing by simply doing % 1 (modulus 1). To get the fractional to display right, you'll have to split it out yourself:

FormatDateTime("%a %d %b %H:%M:%S.",MyTime) + mid(format("%.3f",mytime),1,10)

Change the .3 to however many decimals you want, possibly increasing the 10.

Like most DAQFactory functions, the above will work on an array as well.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.