Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Format String to Date SSRS 2005

Posted on 2010-09-15
5
Medium Priority
?
576 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

926 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