Link to home
Start Free TrialLog in
Avatar of VTFatcat1973
VTFatcat1973

asked on

Format String to Date SSRS 2005

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 ;-)
Avatar of BostonMA
BostonMA
Flag of United States of America image

Try?

format(Cdate(Fields!Well_Child_Visit_Adolescent.Value
), "MMMMMMMM dd, yyyy")
Avatar of VTFatcat1973
VTFatcat1973

ASKER

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 ;-)
ASKER CERTIFIED SOLUTION
Avatar of AliSyed
AliSyed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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 ) )

   
)
Awesome ;-)