How to show Last Date of previous month and First Date of Previous month

Jeetu_choudhary12
Posted by Jeetu_choudhary12 under Sql Server category on | Points: 40 | Views : 2209
DECLARE @mydate DATETIME
Declare @save datetime
SELECT @mydate = '08/13/2011'

SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)),@mydate),101) ,
'Last Day of Previous Month'
UNION
SELECT CONVERT(VARCHAR(25),dateadd(m,-1,DATEADD(dd,-(DAY(getdate())-1),getdate())),103) AS Date_Value,
'First Day of Last Month' AS Date_Typ

Comments or Responses

Posted by: T.saravanan on: 9/12/2011 Level:Silver | Status: [Member] [MVP] | Points: 10
Hi,

Kindly post your code inside the code tag and also give the output of your query then only user easily to identitfy the uses of this query.

Login to post response