Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to use BETWEEN ? If any alternative for this?

596585Mar 2 2009 — edited Mar 2 2009
Hi,

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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 30 2009
Added on Mar 2 2009
6 comments
552 views