0

This is my query I gave from month and to month for retrieve re leaving employee within that months

select 
ED.EmpName,
ED.EmpNo,
OP.Dateofjoining,
ED.deactivedate,
DATEDIFF(MM,OP.Dateofjoining,ED.deactivedate) as Totalmonth
from EmployeeDetails ED 
inner join Officialprofile OP on ED.EmpNo=OP.EmpNo 

inner join SalaryDetails SD on ED.ExisistingCode=SD.ExisistingCode 
inner join MonthDetails MD on SD.Month=MD.Months 

where ED.Lcode='UNIT I'and SD.Year='2013' and ED.ActivateMode='N'
and MD.Months>='Augus and MD.Months<='December'  

I got result no of month using datediff with between to months but in asp.net I have one textbox in that textbox if i give 3 means I want first 3 month employee only

slek
  • 309
  • 6
  • 17
  • Can you properly specify what actually are you looking for? If possible, provide some sample data. – iVad Mar 07 '14 at 07:09

1 Answers1

0

Insted of MD.Months>='Augus and MD.Months<='December' use DATEPART(mm,D.deactivedate) < = 3. Insted of "3", you can pass value of your text box.

AK47
  • 3,707
  • 3
  • 17
  • 36