Solved

Get Current Year Syntax in Switch Statement SSRS 2005

Posted on 2010-11-12
5
816 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
  • 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 200 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 26

Accepted Solution

by:
Shaun Kline earned 300 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now