January 3, 2009 at 2:39 pm
I have an apointment table which contains an apointment date column (smalldatetime). Value of this column is the date plus the time of the apointment.
My goal in to get all the apointments of a specific day.
My stored procedure for this request has one parameter (@specific_day smalldatetime) which contains a date (without time)
Select * from Apointment
Where apointment_date = @specific_day
This query always return 0 row and I know why, it's because all the apointments have a time and my parameter don't (well I guess it's 00:00:00) and so there is no matching.
So what should I do?
Than you
Martin
January 3, 2009 at 2:56 pm
Select * from Apointment
Where apointment_date >= @specific_day AND apointment_date < DATEADD(DD, @specific_day, 1)
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
January 3, 2009 at 8:54 pm
Just to be absolutely correct... the DATEADD portion of the code should be the following...
DATEADD(DD, 1, @specific_day)
--Jeff Moden
Change is inevitable... Change for the better is not.
January 4, 2009 at 3:27 am
Jeff Moden (1/3/2009)
Just to be absolutely correct... the DATEADD portion of the code should be the following...DATEADD(DD, 1, @specific_day)
Oops...thanks Jeff.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply