If the column data type is TIMESTAMP
as the OP has written in a comment to Sandra Rossi's excellent answer then there are actually three conversions required to make the selection work as expected.
- turn the first selection parameter (between a ...) into a date
- turn the second selection parameter (between ... and b) into a date
- turn the timestamp column
DocDate
into a date
This looks like this:
select
*
from
OPDN A
where
to_date(A."DocDate") between to_date('01/01/2020', 'MM/DD/YYYY')
and to_date('01/31/2020', 'MM/DD/YYYY');
The conversion of the selection parameters with the help of format-strings should be obvious, and the result is the same information in a SQL date data type.
The third conversion (to_date(a."DocDate")
) might be surprising, but is rather important.
The way the selection is meant to work is to include everything from the very start of the selection period to the very end. If the input filters are simply converted to timestamps then they will have the time-component of 00:00
(midnight), as no specifics about the time of day are provided.
This will lead to all "DocDate" values after midnight to be excluded.
The correct level of comparison here is date, therefore the "DocDate" also needs to be converted to the hour-less date
data type.
p.s. I just realized that the selection criteria are given in MM/DD/YYYY
format which is probably the reason for the conversion error the OP received earlier.