What I thought was simple turned out to be a nightmare . . .
The table I am trying to get the data out of is very simple:
R_TYPE (string)
R_PRICE (currency)
S_DATE (date)
E_DATE (date)
I run:
SELECT *
FROM MYTABLE
WHERE R_TYPE = :a1
AND R_PRICE BETWEEN S_DATE = :a2
AND E_DATE = :a3
Parameters are:
ABSQuery1.params.ParamByName('a1').asString :=cxTextEdit;
ABSQuery1.params.ParamByName('a2').asDate := DateTimePicker1;
ABSQuery1.params.ParamByName('a3').asDate := DateTimePicker2;
But it wont work…. Any ideas?
Your query is muddled: Price can’t be between the boolean result of date comparisons.
If the date picker is picking any price that had its entire duration (ie it started and ended) between the dates picked, use this:
If the date picker is picking any price that had some duration between the dates picked (ie there was at least some overlap of the date range picked and the price’s date range), use this: