LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting DATETIME milliseconds from SQL Database into Labview

Solved!
Go to solution

I just realized there is a typo in that last statement.  It should be:

 

SELECT DATEPART(ms,Start_Test_Time) FROM Engine_Tests

 

Message Edited by Matthew Kelton on 08-13-2009 03:14 PM
0 Kudos
Message 11 of 13
(1,029 Views)

Matthew,

 

Many thanks for the great answer. Still a very usefull solution to get a dateTime -value or timestamp with milliseconds accuracy back into LabVIEW through the ADO driver (Database Connectivity Toolkit).

 

-Roger

0 Kudos
Message 12 of 13
(898 Views)

 

I'm adding to this as I found this thread when trying to find a solution to import datetime2 formatted data from SQL into LabView. I believe this thread solution is great as long as log time is <1s, anything >1s then the received data could get confusing (maybe not to the programmer but to a third party).

 

For some reason, LabView Variant to data vi cannot interpret Datetime2 formatted data from SQL as time based. However it can happily interpret datetime formatted data, something I find most odd as datetime2 has been around since 2008!?

 

There are various part solutions available on the forum but I could not find an exact solution. One method found in the forums to set the type in variant to data as a String and then use scan from string vi to steer LabView to interpret the string as a time stamp. The key is, and this is where other posts have been misleading (to me as a beginner), the instruction in the format string constant.

 

Attached file, SQLdt2toTime.vi is a simple vi that should perform the conversion. There is also a screen shot of the calling vi so one can see how it is being used in context.

 

The relevance to this post is that the output builds an array where the 2nd column in this instance is time in ms but it could be as small as ns, useful for experiments with sampling periods >1s.

 

Download All
Message 13 of 13
(707 Views)