Need Some SqlServer Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ambelkar
    New Member
    • Apr 2007
    • 6

    Need Some SqlServer Help

    hi,
    I have written the following code to get MonthEndDate,Ru nDate,MonthStar tDate.
    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(S UBSTRING(CONVER T(varchar, GETDATE() - DAY(GETDATE()), 113), 1, 11)), ' ', '-')
    as MonthEndDate,
    '01' + '-' + UPPER(substring (datename(m,get date()),1,3)) + '-' + cast(datepart(y yyy,getdate())a s varchar)
    as RunDate,
    '01' + '-' + 'OCT' + '-' + cast((datepart( yyyy,getdate())-) as varchar)
    as MonthStartDate
Working...