In line WHERE NVL(SCH_END_DATE,SCH_START_DATE) BETWEEN '$(vfrom)' and '$(vto)'
you have implicit conversion of string '$(vfrom)' to date. That's not going to work.
Assuming that vfrom and vto are declared as date, the line should be like this WHERE NVL(SCH_END_DATE,SCH_START_DATE) BETWEEN vfrom and vto
.