How to use BETWEEN ? If any alternative for this?
596585Mar 2 2009 — edited Mar 2 2009Hi,
I have a table X with column start date and end date. Start date can be any date like 04-MAR-09, 03-DEC-08.
In my query I have a requirement like,
SELECT a.name
b.address
FROM X a
,Y b
WHERE a.id = b.id
AND to_date(p_period,'MON-YYYY') BETWEEN a.start_date and NVL(end_date,last_day(to_date(pe_period,'MON-YYYY')))
Here pe_period is a parameter with the vaue as DEC-2008 , MAR-2009.
My problem is,
When I say to_date of DEC-2008 then it wll be 01-DEC-08. So when start_date column in table X has value as 04-DEC-08 and if I check BETWEEN, it will fail for me.
So how to resolve this issue?
To check BETWEEN I need to convert the period into date ,since period is a VARCHAR2 which will not work.
Please somebody help me in this.
Thanks
Alka