ssisado.netquickbooksqodbc

SSIS ADO.NET Source - SQL Command Query Error


I have a problem where I try to read some data from QuickBooks Desktop file in SSIS through ADO.NET Source using QODBC driver. Driver is set up correctly, because I am able to preview table contents of the file like so enter image description here

I am also successful in using SQL Command access mode when I do a simple query like SELECT * FROM Item.
But the moment I try to use SQL Command to incorporate a WHERE clause against TimeModified field like so:
SELECT * FROM Item WHERE TimeModified >= '12/21/2022 1:16:34 PM'
and try to preview I get an error saying this: enter image description here
Now, I sent that row by using table access mode into a derived column and looked up what type TimeModified column uses and saw that it uses DBTIMESTAMP. So I suspected that you can't use the >= operator on that type, so what I also tried in my query is utilizing the DATE() function on the WHERE clause, omitting the time piece like so (Although ideally I would like to keep the hours to be able to use them in my query as time is important but for test sake): enter image description here But as you can see I got the Expected Lexical Element Not Found error.

I originally intended for this to work through an expression in which I obtain a value for a variable of most recent date by querying from a database prior this step and then get the items from the Item table that are older than said date. However, now I completely cut the expression idea just for the sake of trying to get this to work but it doesn't seem like it wants to. Am I doing something wrong? I made some querying in SQL against a date field by using strings of various formats like I showed earlier and those queries in SQL Server all succeeded but here nothing works.

If you are interested how the connection to QuickBooks Desktop is made I am using 32bit QODBC Driver which you can see there as 'QuickBooks Data' in the ADO.NET Source.

Thank you in advance for your help!


Solution

  • So I figured it out. Apparently with QODBC when it comes to timestamps you have to query them by doing something like this:
    SELECT * FROM Item WHERE TimeModified >= {ts '2022-12-16 15:05:55.000'} ORDER BY TimeModified DESC
    Here is some more info: https://support.flexquarters.com/esupport/index.php?/Knowledgebase/Article/View/2407/0/qodbc-desktop-troubleshooting-problems-with-date-format