469,076 Members | 1,529 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,076 developers. It's quick & easy.

Need Some SqlServer Help

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
May 14 '07 #1
0 824

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by Mauricio | last post: by
2 posts views Thread by XML Beginner | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.