I have a stored procedure that retrieves records based on dates corresponding to the input date, which still works. Both dates in the table and my input date are formatted as date and time.
Instead of comparing full dates, I would like to change this so that it only compares the month and day, so that it works with any year for input.
Example: The
date in the table is saved as 2013-04-30, and my input date 2014-04-30. I want the stored procedure to still return this record, independent of the year, for the month and day.
My stored procedure:
ALTER PROCEDURE [dbo].[FetchDays]
@inputDate datetime
AS
BEGIN
SET NOCOUNT ON;
SELECT dateID,
dayDT,
countries,
regions
FROM DaysDT
WHERE dayDT = @inputDate
FOR XML PATH('daysFixed'), ELEMENTS, TYPE, ROOT('root')
END
Thanks so much for any help with this, Mike.