In Our package we had where clause like below.
pp.start_date >= nvl(TO_DATE('01-JAN-2018', 'RRRR/MM/DD HH24:MI:SS'), pp.start_date)
It was working perfectly in customer environment. But since format was 'RRRR/MM/DD HH24:MI:SS' so we changed the date like below.
pp.start_date >= nvl(TO_DATE('2018/01/01', 'RRRR/MM/DD HH24:MI:SS'), pp.start_date)
Ideally it should work because we have given proper format. in the first case it is returning 679 rows but in second case it is returning 0 rows. 679 correct number of rows we have.
What is wrong with second NVL command?
RRRRis a valid modifier.RRwas intended to round a 2-digit year up or down to get the correct century. If you already have a 4-digit year, then useYYYY.RRRRgives you something it doesn't guarantee that it is correctTO_DATE('01-JAN-2018','RRRR/MM/DD HH24:MI:SS')could possibly be "working perfectly". That gives me20-JAN-2001 18:00:00. Also, why would you hardcode anyTO_DATEexpression when you could use a standard date literal?