Click here to Skip to main content
15,900,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i m develeloping leave application
i have 1 doubt

employee apply leave 25 oct2012-27 oct2012
employee come and again apply for leave 25oct2012-1nov2012
then i have to validate date for 2nd time ,how to validate date
Posted
Comments
AmitGajjar 22-Aug-12 2:55am    
it seems like for your all issues you are posting a question. try somthing and if you really stuck then post the question.
invisible@123 22-Aug-12 3:00am    
its nothing like that sir,i try if i m not able to solve then only i post question
ridoy 22-Aug-12 3:19am    
question isn't clear...what do you mean by validate date for 2nd time?

1 solution

Let us say your table column names are Empid, Fromdate, todate

then
SQL
create proc sp_saveleave
(@empid int,
@from datetime,
@to datetime)
as
begin
declare @count int
select @count=count(1) from tbl_leave where empid=@empid
and (@from between fromdate and todate or @to between fromdate and todate)

if @count>0
print 'already applied leave for one or more days in the same period'
else
insert into tbl_leave values(@empid,@from,@to)

end
 
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