May 16, 2007 at 11:13 am
hey i have the following proc, but it's returning null value.
[dbo]
.[Get_Appointments]
@this_date
datetime
as
Select
dbo.Patient_Info.Docket_num, dbo.Patient_Info.Last_Name,
dbo
.Patient_Info.First_Name,dbo.Scheduled_Appointment.App_Date
From
Patient_Info inner join Scheduled_Appointment
on
Patient_Info.KPAIDS_NO = Scheduled_Appointment.KPAIDS_NO
Where
dbo.Scheduled_Appointment.App_Date = convert(varchar(10),@this_date, 101)
Order
by dbo.Scheduled_Appointment.App_Date
i tested it using the following date format>> 5/17/2007
thx for ur help
May 16, 2007 at 11:22 am
Can you post a sample of what it is returning?
-SQLBill
May 16, 2007 at 11:28 am
should return>> ex
id First Name LastName Appiontment Date .......etc
23 bill cower 05/17/2007 ...........etc
but it returns Null
like
id First Name LastName Appointment Date..............etc
nothing here....
May 16, 2007 at 10:17 pm
Tell me... is AppointmentDate a VARCHAR column?
--Jeff Moden
Change is inevitable... Change for the better is not.
May 17, 2007 at 7:12 am
1. Are you sure there is data in the "Scheduled_Appointment" table for the date tested? (if not then where clause/join fails)
2. If #1 is true are you sure there is data (patients) in the "Patient_Info" table that have appointments for the date being tested? (if not then where clause/join fails)
3. If #1 and #2 are true then are you sure that scheduled_appointment.app_date is a varchar column? If it is a datetime column does it have "time" data included in it? If so the following proves you will never get a match:
declare @t_ table (date_ datetime)
insert into @t_ values (getdate())
select * from @t_ where date_ = convert(varchar(10),getdate(),101)
select * from @t_ where convert(varchar(10),date_,101) = convert(varchar(10),getdate(),101)
--First select statement returns no records because table record has time included and your test does not.
--Second select will result in a match.
James.
May 17, 2007 at 9:26 am
1. AppointmentDate is a Datetime data type.
ooops srry guys my bad i had AppointmentDate as char.
i changed it to datetime, now it works
thx again
May 17, 2007 at 9:34 am
Does AppointmentDate contain time information, or is the time portion all "zeros"? If it has time values then your query will never return anything. See the "second" select statement in my example for a method of over comming the problem (there is more than one way to fix it, but what I did will work).
James.
May 17, 2007 at 9:37 am
my mistake JLK... it's working now thx
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply