Hi Jayakumar,
DECLARE @dtDate DATE
SET @dtDate = '08/13/2013'
SELECT convert(date,DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@dtDate)+1,0)))
Your query return Last Day of current Month...
For Last Day of Last Month you should remove +1 after DATEDIFF() function
SELECT convert(date,DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@dtDate)[b]+1[/b],0)))
Final Query should be
SELECT convert(date,DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@dtDate),0)))
However your query is too complicated... You have used 4 functions in your query...
Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif
Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator