Solved

How can I query rows using a date field properly?

Posted on 2008-06-26
3
244 Views
Last Modified: 2013-12-19
Hi,
This is my line of code (which doesn't work), how can this modified to retrieve rows?

AND CBPV.BP_START_DATE >= to_date(:bp_period_start,'DD/MM/YYYY')
AND CBPV.BP_START_DATE <= to_date(:bp_period_end,'DD/MM/YYYY')

bp_start_date is a date field type, sample data
6/1/2008 , 4/23/2008

Thanks,
R
0
Comment
Question by:Rhonda Carroll
3 Comments
 

Expert Comment

by:Dranth
ID: 21875409
Make sure the values used for the parameters are strings and not date.

0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 21877522
is the field  CBPV.BP_START_DATE a DATE type field, or a Varchar field?

you might try this (if CBVP.BP_START_DATE is a DATE field):

AND TO_CHAR(CBPV.BP_START_DATE, 'YYYYMMDD') >= to_char(:bp_period_start,'YYYYMMDD')
AND TO_CHAR(CBPV.BP_START_DATE, 'YYYYMMDD') <= to_char(:bp_period_end,'YYYYMMDD')


AW


0
 
LVL 10

Accepted Solution

by:
dbmullen earned 125 total points
ID: 21880518
a date is a date is a date, regardless of how you display it.  it's saved as a DATE

declare
bp_period_start date := to_date('20080101','yyyymmdd');
bp_period_end date := trunc(sysdate);
begin
...

select *
from ...
where ...
AND CBPV.BP_START_DATE >= :bp_period_start
AND CBPV.BP_START_DATE <= :bp_period_end
...
;
end;
/
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question