Hi,
I am trying to pass the date from “Date&Time Input” node as a variable to SQL.
Unfortunately “Date” (ie. “2022-03-03”) is being calculated by knime when passed to “DB query reader”.
So instead “2022-03-03” DB query see variable as 2016 which is result of 2022-3-3
Any idea? Should I first transform “date” input to string somehow?
Try transforming it to a quoted string for the DB Query Reader.
As far as I can tell, KNIME first injects the value of the Flow Variables into the SQL statement. If it’s a Date value, it will put an ISO formatted date, same as if you’d transform it to a string yourself (2022-03-03). The SQL statement is then passed to the DB where it sees something it will happily interpret as subtraction.
Using string with extra quotes, leaves the DB no other choice as to interpret "2022-03-03" as string. (It can even parse it back into a Date if it needs to). I learned this the hard way. I think I even needed to quote twice, so you might want to check that as well if quoting once doesn’t work.