Solved

How can I query rows using a date field properly?

Posted on 2008-06-26
3
249 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

627 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