LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read certain span of data from SQL-database ?

Hi All,
 
I'm using LV 8.5 with Database Connectivity Toolset
 
My aim is read certain time span data from MySQL-database. Let's assume that I have rocorded data from 1.1.2008 to 25.1.2008. My database table contain two columns "timestamp" and "data". How  I can select  e.g. span 20.1.2008 10:00 - 21.1.2008 14:00? I think that I have to use VI "Select Data" and write something to connector "optional clause". I can't find any example how to write clauses to this connector.
 
I managed to select all data but that consumes quite much CPU time and I usually need only smaller data sets.
 
BR,
 
Jim
  
0 Kudos
Message 1 of 2
(2,827 Views)
The VI DB Tools Select Data has an input called (at the top) called "optional clause". You can wire an SQL predicate to this input that control the rows that are returned by the VI. In your case, you want to use what's called a WHERE clause to filter the rows to be the subset you need.

For the toy database I was playing with I had to set the optional clause to: "where startdate > #3/1/2008#" to make the VI return rows which had a startdate field of later than 01-Mar-2008. I was using the JET DB engine, not sure if the same syntax will work for other SQL engines, so your mileage may vary. 🙂

Let me know if you need more information or want to take a look at my example VI.

Cheers!
Pramod


Message Edited by PramodS on 04-09-2008 01:26 AM
0 Kudos
Message 2 of 2
(2,791 Views)