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!

Exec Proc Based on DateTime Fields

Status
Not open for further replies.

Hexonx

Programmer
Jan 10, 2001
102
US
I'm executing a stored procedure that filters on datetime input parms. This is the procedure:

Input parms: @ai_d_startdate (datetime), @ai_d_enddate (datetime)
Code:
-- If no end time, default to 1-hour block of time
if @ai_d_enddate is null
	select @ai_d_enddate = DATEADD(hh, 1, @ai_d_startdate)


-- Convert input parms to compatible format
select @ai_d_startdate = convert(datetime, @ai_d_startdate, 110) --101)
select @ai_d_enddate = convert(datetime, @ai_d_enddate, 110) --101)


-- Constant for Therapist provider type/category
declare @PROVIDER_TYPE_THERAPIST int
select @PROVIDER_TYPE_THERAPIST = 2
 
Select  s.VisitDateTime, s.PatientSchedID,
		s.ServiceID,
		p.Firstname + ' ' + p.lastname 'PatientName', 
		s.VisitReason, 
		r.firstname + ' ' + r.lastname 'TherapistName'
From    Patient p,
		Patient_schedule s,
		provider r
Where   p.patientId = s.patientId and
		r.providerId = s.providerId and
		r.ProviderTypeID = @PROVIDER_TYPE_THERAPIST and
		s.VisitDateTime between @ai_d_startdate and @ai_d_enddate
When I run from CAST SQL Builder (a query analyzer) I get the result set I expect, but when I execute via ADO 2.5, I get an opened Recordset with no records.

I tried setting Parameter types to adDate and adDBDate, but no effect.

The value that the Parameter object is sending to the DB is #1/27/1997 8:00:00 AM#.

No errors are generated on execution.

Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top