LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving records using SQL Date Queries

Hello,

 

I am using Lab Windows CVI 8.5 and also SQL TOolkit for my project. I am using DBMapColumnToChar function for mapping Date to the database. And for retrieving records I am using SQL Query as follows:

 

SELECT * FROM DBTable WHERE DATE_TABLE BETWEEN '%s' AND '%s'",cCurrentDate,cCurrentDate

 

I have given a drop down for selecting dates.

When I execute the query I am not getting the selected date values an instead I am getting some records for which the dates aren't selected...

 

Quick help needed for this..Thanks in advance

0 Kudos
Message 1 of 5
(3,012 Views)

Can anyone help me!!! Its Urgent

0 Kudos
Message 2 of 5
(2,992 Views)
Sorry This is the Query SELECT * FROM DBTable WHERE DATE_TABLE BETWEEN '%s' AND '%s'",cCurrentDate,cPrevDate And Not This SELECT * FROM DBTable WHERE DATE_TABLE BETWEEN '%s' AND '%s'",cCurrentDate,cCurrentDate
0 Kudos
Message 3 of 5
(2,980 Views)

Depending on the database, the date/time structure can be completely different from the structure in CVI.  CVI uses the Windows format for time(), that is the number of seconds since 1900.  The tm struct can break this apart into a date and time structure that is usable.

 

I am using MS Access for the databases and SQL toolkit.  I finally ended up replace the date field with an INT field format, and then store the CVI time (gotten with time()) as an INT value.

 

Easy then to get a search range, store it a tm struct and then convert with mktime() to a calendar time to search with.

 

Hope this helps.  The date/time thing is a never ending struggle.

 

Regards, David E.

0 Kudos
Message 4 of 5
(2,958 Views)

Thanks David E,

 

But I found another way to sort this out,instead of MM/DD/yyyy,I am using yyyy/MM/DD,and I think this sorts out the problem. Waiting for the testing team's result...

0 Kudos
Message 5 of 5
(2,950 Views)