Can I assign a case when to a variable?

  • Can I assign variables like this?

    declare@FiscalYearvarchar(4),

    @PeriodIDvarchar(10)

    set @FiscalYear=case when month(getdate())>9 then year(getdate())+1 else year(getdate()) end

    set @PeriodID=concat(upper(left(datename(month, getdate()),3)),' ', @FiscalYear)

  • Just change the set statements to select

  • Thanx.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply