Solved

Get Current Year Syntax in Switch Statement SSRS 2005

Posted on 2010-11-12
5
827 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Job Hung 17 36
sql query 5 43
install sql server management studio 2008 express error 3 29
Error in sql query statment. 21 43
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

762 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