Solved

Format String to Date SSRS 2005

Posted on 2010-09-15
5
567 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
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…
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 setup several different housekeeping processes for a SQL Server.

627 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