LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Getting DATETIME milliseconds from SQL Database into Labview

Solved!
Go to solution

Getting DATETIME milliseconds from SQL Database into Labview

Hello,

I am trying to extract a timestamp from my database in MS SQL and I am not getting the milliseconds when I fetch the data. Does anyone know how to program sql or labview so I can get the whole timestamp. In SQL I have it set as datetime2. I'll appreciate any help. Thanks 

0 Kudos
Message 1 of 13
(4,009 Views)

Re: Getting DATETIME milliseconds from SQL Database into Labview

Have you confirmed the ms data is in the database?  If so, how exactly are you converting the SQL response to LabVIEW data?  If you are using the variant to data and supplying it with a LabVIEW timestamp, try changing it to a string and verify the data is in the response (you may also be able to probe the variant and see it).  I have had issues with NI's conversions of SQL timestamps into LV timestamps, particularly with bit errors so the timestamp no longer matches the timestamp in the database.  I have had to bring it in as a string, then use Scan From String to convert it into a timestamp reliably.

 

0 Kudos
Message 2 of 13
(4,006 Views)

Re: Getting DATETIME milliseconds from SQL Database into Labview

Thanks for the reply. Yes, the data is in the database I have attached a few pictures of how I am doing it, maybe you can tell me if I am doing something wrong. But as you can see, I have used fetch and fetch all to try to get it and it still does not work.
0 Kudos
Message 3 of 13
(3,989 Views)

Re: Getting DATETIME milliseconds from SQL Database into Labview

There were no images in your response.
0 Kudos
Message 4 of 13
(3,983 Views)

Re: Getting DATETIME milliseconds from SQL Database into Labview

sorry the attachment is not working
0 Kudos
Message 5 of 13
(3,981 Views)

Re: Getting DATETIME milliseconds from SQL Database into Labview

0 Kudos
Message 6 of 13
(3,978 Views)

Re: Getting DATETIME milliseconds from SQL Database into Labview

Do NOT post 3 and 4 MB files. Use Paint to save them as png and a reasonable size.
0 Kudos
Message 7 of 13
(3,965 Views)

Re: Getting DATETIME milliseconds from SQL Database into Labview

0 Kudos
Message 8 of 13
(3,956 Views)
Highlighted
Solution
Accepted by topic author Bertha
08-27-2015 04:09 PM

Re: Getting DATETIME milliseconds from SQL Database into Labview

It looks like it is an ADO driver issue, not specific to LabVIEW.  If you use the query

 

SELECT Convert(varchar,Start_Test_Time,21) FROM Engine_Tests

 

you can get the data back in a string and convert to a timestamp.

 

You can also use

 

SELECT DATEPART(msStart_Test_Time) FROM Engine_Tests

 

to just get the ms part.  More info on DATEPART can be found here:

 

http://msdn.microsoft.com/en-us/library/ms174420(SQL.90).aspx

 

 

Message 9 of 13
(3,924 Views)

Re: Getting DATETIME milliseconds from SQL Database into Labview

This really helped! Thank you for your time
0 Kudos
Message 10 of 13
(3,913 Views)