I had a query and I am trying to get the yesterday date at 00:00:00 and the previous month date at 00:00:00. This is my query:
SELECT DATEADD( DD,-2, CONVERT( CHAR(8) , getdate() , 112 )) 'Yesterday', CONVERT( CHAR(8) ,DATEADD(ms,-3, DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0))) , 112 ) 'Last Day of Last Month'
The result is as follows:
Last Day of Last Month:20150430
What is wrong here? Even if I move the convert I still getting this format. Is my approach correct?