hi,
I have written the following code to get MonthEndDate,RunDate,MonthStartDate.
It is giving year in MonthStartDate 2005, upto sep07 it is ok.When it come to OCT 07 it has to display monstartdate year as 2006.How can I do this.Please help me
SELECT REPLACE(upper(SUBSTRING(CONVERT(varchar, GETDATE() - DAY(GETDATE()), 113), 1, 11)), ' ', '-')
as MonthEndDate,
'01' + '-' + UPPER(substring(datename(m,getdate()),1,3)) + '-' + cast(datepart(yyyy,getdate())as varchar)
as RunDate,
'01' + '-' + 'OCT' + '-' + cast((datepart(yyyy,getdate())-) as varchar)
as MonthStartDate