I have a query that declares and sets a datetime variable at the very beginning:
declare @_NextAppt as datetime set @_NextAppt = dateadd(dd,3,getdate())
when I check it and execute a select @_NextAppt it returns three days from today which is what I want.
The problem occurs in my next select statement when I use
where table.apptdate = @_NextAppt
The query returns no rows.
Here's the sample query:
select distinct PatID, StaffID from dbo.Appointments where PatID is not null and ApptDate = @_NextAppt
I can get everything to work if I replace getdate() with an exact date like '11/09/2016'. But that doesn't work long term for my report.
What am I missing? I'm relatively new to SQL and self taught so I'm sure there is some SQL quirk that I don't know about.