I’m using a database to store details about games for my project, and I want to create a filter to check for a specific date. I’ve tried a few potential solutions to no success.
None of the solutions mentioned have worked for me, where they seem to have worked for others. Is it to do with the AND
messing it up? Because I know the Team
statements worked fine before I added the date checks
Data in the Database
Code to create my stored procedure
CREATE PROCEDURE [dbo].sproc_tblGame_FilterByTeamAndDate
@Team varchar(50),
@GameDate date
AS
SELECT * FROM Games WHERE (Home like @Team+'%' OR Away like @Team+'%') AND CAST(GameDate AS date) = @GameDate
RETURN 0
I’m leaving the @Team
value blank and the @GameDate
is 05/06/2024
as shown in the image
Other solutions I have tried:
CONVERT(DATETIME, FLOOR(CONVERT(FLOAT, GameDate))) = @GameDate
datediff(dd, GameDate, @GameDate) = 0
date('GameDate') = @GameDate;
GameDate>=@GameDate and GameDate<dateadd(dd,1,@GameDate)