比较表中的日期而不考虑当天! [英] Compare date in table without considering the day !

查看:77
本文介绍了比较表中的日期而不考虑当天!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,



我制作了一个存储过程,可以在特定月份获得员工贷款,但我从开发人员那里收到年份和月份作为参数,表中的列是日期,所以我想知道如何将两个参数设置为日期并将其与表中的日期进行比较而不用考虑当天



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 = ?

推荐答案

试试这个:

try this:
where month(loanDate)=@MonthID and year(loanDate)=@YearID 


WHERE MONTH(LoanDate) = 4 AND YEAR(LoanDate)=2013



参考:

[ ^ ]

[ ^ ]


这篇关于比较表中的日期而不考虑当天!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆