Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Get Current Year Syntax in Switch Statement SSRS 2005

Posted on 2010-11-12
5
Medium Priority
?
840 Views
Last Modified: 2012-05-10
In the following Switch statment, I have hard-coded the date 12/31/2010; however what I really need to do is have 0000 = 12/31/CurrentYear. Can someone please help me with the syntax.
Thanks,

=Switch
(   Fields!Combo_3.Value = 0001,DateAdd("D",730,Fields!Birthdate.Value),
    Fields!Combo_3.Value = 9999,"N/A",
    Fields!Combo_3.Value = 0000,CStr("12/31/2010"),
    Fields!Combo_3.Value = 0002,"Past Due",
    Fields!Combo_3.Value,Format( Mid( Fields!Combo_3.Value ,5,2 ) & "/" &
    Right( Fields!Combo_3.Value , 2 ) & "/" &
    Left( Fields!Combo_3.Value , 4 ) )  

   
   
)
0
Comment
Question by:VTFatcat1973
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 34123449
try this

year(getdate())

or

Select datepart(year,getdate())
0
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 800 total points
ID: 34123474
doh!, thats just the year part

not sure if this would work though

,CStr("12/31/" + year(getdate())),

or perhap build like this

 "12/31/" + cast(year(getdate()) as varchar)
0
 
LVL 27

Accepted Solution

by:
Shaun Kline earned 1200 total points
ID: 34123505
Or maybe
"12/31/" & CStr(Year(Today()))
since it looks like SSRS code, not T-SQL code.

0
 
LVL 65

Expert Comment

by:rockiroads
ID: 34123549
yes true lol. I missed SSRS in the title and read the zone, doh!
0
 

Author Closing Comment

by:VTFatcat1973
ID: 34123740
You both were a big help. I split up the points see I kinda mislead with T-SQL as it was SSRS code. Shaun's Syntax was right on ;-) Thanks
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how the fundamental information of how to create a table.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question