Click here to Skip to main content
15,915,752 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI ,

I made a stored procedure that get loans of employees in specific month but I'm receive the year and month from developer as a parameter , the column in table is date so i want to know how i can set the two paramter as a date and compare it with date in table without cosidering the day

create proc GetLoans
@YearID int
,@MonthID int
as
SELECT     Users.FullName, Loans.AmountPaid, Loans.LoanDate
FROM         Loans INNER JOIN
                      Contracts INNER JOIN
                      Users ON Contracts.UserID = Users.UserID ON Loans.UserID = Users.UserID
where LoanDate = ?
Posted

try this:
SQL
where month(loanDate)=@MonthID and year(loanDate)=@YearID 
 
Share this answer
 
WHERE MONTH(LoanDate) = 4 AND YEAR(LoanDate)=2013

Refer:
MONTH[^]
YEAR[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900