ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Searching SQL database for selected date

LabVIEW 8.6 Professional with Data Connectivity Toolkit 1.0.2.  SQL database is a flat (non-linked) table on an IBM SQL server.

 

  I'm using the 'Complete SQL Session.vi' to search for records with a particular date stamp.  This information is used to update tally displays on a factory floor.

 

The SQL statement for example is:  SELECT * FROM TestResults WHERE Date_Test LIKE '%4/8/2011%';

 

  If the SQL table column Date_Test was created using the Text Data Type (MS Access), I have no problems.  However, if the same column in a different table was created using the Date/Time Data Type (MS Access), it won't return any records.  I can change the SQL statement to read:  WHERE Date_Test LIKE '%2011%'; It will return all the records for the entire year.

 

Has anyone run across this problem before, and found a workaround for it?

0 Kudos
Message 1 of 4
(3,573 Views)

Greetings b.headley!

 

Would the following example be of any help in your situation?

 

DataBase: Gathering Information in a Specific Date/Time Range

http://decibel.ni.com/content/docs/DOC-4932

 

 

Michael G

Michael G.
Applications Engineer
National Instruments
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Self-realization: I was thinking of the immortal words of Socrates, who said, "... I drank what?"
Message 2 of 4
(3,557 Views)

Michael,

 

  Thanks for pointing the app note, unfortunately I'm not able to open the example (written in LV 2009, I have LV 8.6).

 

  Using the description as a guide, I tried using the 'Complete SQL Session.vi' again, but using the BETWEEN statement instead of the LIKE or comparative statements.  Lo and behold, it worked!

 

  An example 'working' statement read:

 

  SELECT * FROM Test_Results WHERE Date_Test BETWEEN '04/13/2011 00:00' AND '04/13/2011 23:59';

 

  Thanks for the assist - it's truely appreciated!

Message 3 of 4
(3,540 Views)

Was struggling with this issue the past day, this was what I needed. I won't have to pull anymore of my hair out thanks to this post.

0 Kudos
Message 4 of 4
(3,460 Views)