LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Database retrieving records based on time stamp

Hello all,

                       I just  want to know that SQL query to retrieve specific time stamp record from the database using SQL server will work when same query is executed using SQL execute query.vi in labview.

             

                      Its not working actually.

 

My query is,

 

SELECT * FROM table name where col_name between 'date/time 2012-12-13 10:48:00' and 'date/time 2012-12-13 10:55:00'

 

I am using mdb file. This date/time 2012-12-13 10:48:00 is first time stamp to be searched.. This is string comes from DB Tools format datetime string.vi 

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
Message 1 of 11
(4,098 Views)

A MS-Access query of a datetime field needs to be delimited wth the # (number sign / hash mark)

 

Something like:

 

SELECT * FROM table name where col_name between #2012-12-13 10:48:00# and #2012-12-13 10:55:00#

 

I've never used the between condition; I don't know if it will work reliably with Access. I would normally use  >= and <= comparisons

 

Important: the # is specific to Access. We converted from Access to SQL Server in the last year and had to find all the places that used the "#' in our LabVIEW code and replace with a single quote.

 

0 Kudos
Message 2 of 11
(4,087 Views)

HI PhillipBrooks,

                                      Still not working. I am able to retrieve specific time stamp record from the database using little complex method. Just got an idea that it can be done by executing simpler way,

 

I though of retrieving using SQL query. 

Any other idea ?

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 3 of 11
(4,082 Views)
What is the datatype of the column? Are you using SQL Server? I thought you said you were, but the previous answer you got gave the syntax for a JET (MS Access) database.

Finally, when you do a simple query of that column, how is the date formatted?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 11
(4,080 Views)

No i am trying to retrieve through labview only. for crosscheck i used SQL server. I am using JET only. My time column is of date/time type with format is '13-12-2012 10:48:00'. i verfied this 

 

 

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 5 of 11
(4,075 Views)

So, the query Phillip posted should have worked. What was the result when you ran it from within LV?

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 11
(4,067 Views)

I may be wrong, but I thought the datetime string when using Access was locale specific. If you are using US, then the date portion should be mm/dd/yyyy instead of yyyy-mm-dd.

 

You could use the %c format specifier to get the localized format and then wrap that with the # marks.

 

0 Kudos
Message 7 of 11
(4,064 Views)

HI 

 

                                   I am getting error -2147217913 states Data type mismatch in criteria expression.

 

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 8 of 11
(4,036 Views)

For the cross check i used same command for MDF file, My query is

 

SELECT * FROM Data_120 WHERE Time_Stamp BETWEEN '2012-07-07 15:00:00.000' and '2012-07-07 15:14:00.000'

 

This query works fine when i am executing same query in SQL server but when i executes same commad using labview it says 'Invalid object name'

 

 

God knows what is happening.

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 9 of 11
(4,034 Views)

Hello all, 

           

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 10 of 11
(4,030 Views)