Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Begin and End Date Parameter 3

Status
Not open for further replies.

fhurmuzlu

Programmer
Nov 16, 2004
52
US
I have this query in Command
select (select name from mastlocationcode where type = 'DIST' and code = m.district) as "Division",
count(incident_num) as "Incidents"
from incident i, mastlocation m
where m.recnum = i.locn_rec
and to_date(reported_on) >= '01-jan-2011'
and to_date(reported_on) <= '31-dec-2011'
group by m.district
order by m.district

The client wants monthly report with two parameter Begin and End date (like the client wants to enter begin and end date for each month and get the result (like Begin Date (3/1/2011 and End date 3/31/2011) in this case client gets monthly report for march.

Please I need help
 
Hi,

Create the FirstDate and LastDate paarameters in the SQL command,
and use them in the query instead of static dates:

select (select name from mastlocationcode where type = 'DIST' and code = m.district) as "Division",
count(incident_num) as "Incidents"
from incident i, mastlocation m
where m.recnum = i.locn_rec
and to_date(reported_on) >= ?FirsDate
and to_date(reported_on) <= ?LastDate
group by m.district
order by m.district

Dana
 
After creating parameter in the sql command I am getting Error message (Sql command not properly ended)
 
First off any parameter in the command must have the curly brackets around them (i.e, {?FirstDate}). If you are using MS SQL (other SQL's may work different), I also believe you need single quotes around the parameters (i.e, '{?FirstDate}').

I hope this helps.
 
For date params, you only need the curly brackets - no quotes. You just need the quotes for single-value strings.

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top