Solved

Format String to Date SSRS 2005

Posted on 2010-09-15
5
561 Views
Last Modified: 2012-05-10
I need assistance on the code below:
=Switch
(
    Fields!Well_Child_Visit_Adolescent.Value = 9999,"N/A",
    Fields!Well_Child_Visit_Adolescent.Value = 0000,CStr("12/31/2010"),
    Fields!Well_Child_Visit_Adolescent.Value = 0001,DateAdd("D",730,Fields!Birthdate.Value),
    Fields!Well_Child_Visit_Adolescent.Value = 0002,"Past Due",
    Fields!Well_Child_Visit_Adolescent.Value,Fields!Well_Child_Visit_Adolescent.Value
   
   
)

The last item in the switch returns the data in a string for example(20100625) to represent the date as it should. I need the end-user to see the string formatted as the following : 06/25/2010. I need the syntax to accomplish this is Reporting Services in the Switch Function. Please Help!!! I am beating my head against the wall ;-)
0
Comment
Question by:VTFatcat1973
  • 3
5 Comments
 
LVL 4

Expert Comment

by:BostonMA
ID: 33682764
Try?

format(Cdate(Fields!Well_Child_Visit_Adolescent.Value
), "MMMMMMMM dd, yyyy")
0
 

Author Comment

by:VTFatcat1973
ID: 33682834
It does not like that ;-( I get the following error cannot convert string to date type. I believe that I am going to have to use left, right functions, I am just not sure how to do it ;-)
0
 
LVL 6

Accepted Solution

by:
AliSyed earned 500 total points
ID: 33682843
=Format( CDate( Left( Fields!Well_Child_Visit_Adolescent.Value , 4 ) & "/" &
 Mid( Fields!Well_Child_Visit_Adolescent.Value , 5, 2 ) & "/" &
 Right( Fields!Well_Child_Visit_Adolescent.Value , 2 )), "yyyy/MM/dd" )
0
 

Author Comment

by:VTFatcat1973
ID: 33682954
Thank-you so much- I had to modify it just a bit- but it works great. here is my final code
=Switch
(
    Fields!Well_Child_Visit_Adolescent.Value = 9999,"N/A",
    Fields!Well_Child_Visit_Adolescent.Value = 0000,CStr("12/31/2010"),
    Fields!Well_Child_Visit_Adolescent.Value = 0001,DateAdd("D",730,Fields!Birthdate.Value),
    Fields!Well_Child_Visit_Adolescent.Value = 0002,"Past Due",
    Fields!Well_Child_Visit_Adolescent.Value,Format( Left( Fields!Well_Child_Visit_Adolescent.Value , 4 ) & "/" &
 Mid( Fields!Well_Child_Visit_Adolescent.Value , 5, 2 ) & "/" &
 Right( Fields!Well_Child_Visit_Adolescent.Value , 2 ) )

   
)
0
 

Author Closing Comment

by:VTFatcat1973
ID: 33682958
Awesome ;-)
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Hi, In my previous Article  (http://www.experts-exchange.com/Database/Reporting/A_15199-Introduction-to-Microstrategy.html)I discussed some basic understanding of Microstrategy that how we can get in Intro of Microstrategy (MSTR). Now it's tim…
How to increase the row limit in Jasper Server.
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
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

820 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