Prasad Bhagat

Prasad Bhagat

  • NA
  • 516
  • 236.4k

how to cal a datetime colum with int values

Jun 23 2015 6:19 AM
Dear all,
 
i have a procedure like bellow,
CREATE PROC USP_ABC
@month int,
@year int ,
as
begin 
select * from tbl
where 
(@month=0 or (SELECT DATEPART(MM, DOJ) FROM dbo.tbl_param_employee_master as month)= @month)and
(@year=0 or (SELECT DATEPART(yy, DOJ) FROM dbo.tbl_param_employee_master as year)= @year)
END 
 
 DOJ Date.
here DOJ datatype is date 
so please suggest me how to call this query

Answers (4)