开发者

How to Compare the user Given date with the table date using Store Procedure

I have one date fields represents StartDate Using CalenderExtender and textbox field Represents ID. Im passing the 2 parameter from Code-Behind(ASP.NET) to Stored Procedure.....

IN the Table having 4 columns ID,StartDate,Enddate and ReturntoWorkDate:

My need is If i pass the paramet开发者_运维百科er from Code-Behind it should compare with StartDate, enddate and ReturntoWorkDate and it should displays the record from the Table.

Examlple In the table ID : 001 startdate : 12-11-2010 EndDate : 12-19-2010 ReturntoWorkDate : 12-20-2010

i'm passing this parameters ID : 001 and Startdate : 12-13-2010

OUTPUT: ID :001 || Startdate : 12-11-2010 || Enddate : 12-19-2010 || ReturntoWorkDate : 12-20-2010

For Above Question NEED STORED PROCEDURE ONLY

This is the code.....

Alter PROCEDURE [dbo].[sp_SearchLeaveDate]
@employeeid varchar(30),
@leavestartdate varchar(30)

As
Begin
Declare @employee varchar(max)
declare @leavestart varchar(Max) 

select @employee = employeeid, @leavestart = leavestartdate from LeaveRequest where employeeid = @employeeid and (between leavestartdate >=@leavestartdate or leaveenddate <= @leavestartdate)

end

Can any one Help me please.............


ALTER PROCEDURE [dbo].[sp_SearchLeaveDate]
@employeeid varchar(30),
@leavestartdate varchar(30)

As
Begin
Declare @employee varchar(max)
declare @leavestart Datetime

set @leavestart = @leavestartdate

select count(*) from LeaveRequest where employeeid = @employeeid and  (@leavestart  between leavestartdate and returndate) and (status = 'Pending' or status = 'Approved')

End
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜