To get the value of month first date & last date int value you can try this:
DECLARE @startOfMonth DATETIME , @MonthID int, @YearId int
DECLARE @endOfMonth DATETIME
DECLARE @FromDate DateTime,@ToDate DateTime
SET @MonthID=2 set @YearId=2014
Select @startOfMonth = CAST(@YearID AS varchar) + '/' + CAST(@MonthID AS varchar) +'/'+ '01'
Select @endOfMonth = CAST(@YearID AS varchar) + '/' + CAST(@MonthID AS varchar) + '/'+ CAST(DAY(DATEADD(DD,-1,DATEADD(MM,DATEDIFF(MM,-1,@startOfMonth),0))) AS varchar)
Set @FromDate=@startOfMonth
Set @ToDate=@endOfMonth
SELECT @FromDate 'MonthStartDate',@ToDate 'MonthEndDate'
Comments
Post a Comment