I am in the process of transitioning Oracle queries to PostgreSQL and I am trying to pass a date range to pull back the results.
The original Oracle query is below:
select
iss_id
,date_created
from issues i
where
trunc(i.date_created)
BETWEEN trunc(TO_DATE(:StartDt ,'mmddyyyy'))
-- ^^^^^^^
AND trunc(TO_DATE(:EndDt ,'mmddyyyy'))
-- ^^^^^^
My problem is with the :StartDt & :EndDt, when this is run in Oravle Developer it will produce a popup box that will allow the user to input a date value for these two variables. What I am looking for is an equivalent to this in PostgreSQL.
Any assistance to this would be greatly appreciated.
TO_DATE. That it appliesTRUNCthen makes no sense, however. A better condition would beWHERE i.date_created >= TO_DATE(:startdt ,'mmddyyyy') AND i.date_created < TO_DATE(:enddt ,'mmddyyyy') + INTERVAL '1' DAYanyhow to allow for the use of an index on date_created and dealing which the fact that in Oracle there exists no pure date type, but only a datetime type (which they inappropriately callDATE).