Probably the reason is the way that date strings are treated. Replace this query line
and pr.end_date NOT BETWEEN $1 AND $2
with this one (i.e. make string-to-date conversion explicit and controlled)
and pr.end_date NOT BETWEEN to_date($1, 'MM/DD/YYYY') AND to_date($2, 'MM/DD/YYYY')
I would suggest that whenever dates, timestamps, time zones or encodings are concerned you always use explicit settings/rules and never rely on defaults.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…