Date parameters in SQL query

Ajayi32

Registered User.
Local time
Today, 01:56
Joined
Feb 21, 2001
Messages
26
The code below works as is but, I need help with the where clause. In its current state I am pulling data for a specific date. I would like to always pull data for the previous date or better yet be able to set it up so the end user can enter parameters for the time they wish.

My apologies if this questions has been asked an answered. I did a search but was unable to get other potential answers to work.

Thanks in adavnce


SELECT
SERVICEDAILY.STARTDATE,
SERVICEDAILY.ENDDATE,
SERVICEDAILY.SERVICENAME,
SERVICEDAILY.SERVICEID,
SERVICEDAILY.CONTACTS,
SERVICEDAILY.ANSWERED,
SERVICEDAILY.AVGTALKTIME,
SERVICEDAILY.ACWTIME,
SERVICEDAILY.ABANDONED
FROM
SERVICEDAILY
WHERE
(SERVICEDAILY.STARTDATE = '1 / 3 / 11')
ORDER BY
SERVICEDAILY.SERVICENAME;
 
If you're querying against a SQL Server db you should put the query in a stored procedure and make the required date a parameter of the stored procedure.

eg.

create proc query_servicedaily_by_date
@paramdate date
as

begin

set nocount on

select
*
from
servicedaily
where
date = @paramdate
end

Then you can call it like this:

query_servicedaily_by_date @paramdate = '2011-01-01'
 

Users who are viewing this thread

Back
Top Bottom