Monday, 23 June 2014

Getting Previous Month Data Using StoredProcedure

create proc usp_getprvmondata
as
begin
select * from loadhistory where loaddate between 
DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) - 1, 0) and
DATEADD(DAY, -(DAY(GETDATE())), GETDATE());
end
exec usp_getprvmondata

No comments:

Post a Comment