Date Format in SSRS

  • I have the date time field. I want extract only Month and the year. How can I do the same.

    Current format of the field is "10/01/2012 hh:mm:ss"

    Need to convert to "October 2012"

    I want to do these changes in SSRS.

  • deepeshdhake (10/2/2012)


    I have the date time field. I want extract only Month and the year. How can I do the same.

    Current format of the field is "10/01/2012 hh:mm:ss"

    Need to convert to "October 2012"

    I want to do these changes in SSRS.

    Assuming your source data field is a datetime datatype and you don't want the day, you could do something like:

    =Format(Fields!YourDate.Value, "MMMM") & " " & CStr(Year(Fields!YourDate.Value))

    HTH,

    Rob

    [font="Tahoma"]*I don't have SSRS open as I type this, so please double check my memory to make sure it works as you wish[/font]

  • Hello Rob,

    Few data is correct and few is wrong. Here is the sample output I am getting:

    Octaber 12

    Jul12 12

    SetpAmer

    What is the problem?

  • Impossible to know without seeing the data, but I'd guess that the field isn't a datetime datatype, but rather a varchar() where not all of the values are correctly formatted dates.

    Take a look at the raw data coming through for that field.

  • Hello,

    Originally, that column has Date as Data type. So, now what to do? IS there any other procedure to do this?

  • =FORMAT(Field!DateField.Value "MMMM yy")

    How about the above?

  • This too doesn't work. Is there any other way to do this.

    With Format(), I am getting some thing like this:

    OctAber

    SetAmber

    etc

  • I still think you have data that isn't a date. Can you take the SQL out of your dataset and manually run it in SMSS? What does that data look like in that field?

    Rob

  • Hello Rob,

    Can u also tell how to covert if the data type is varchar.

    Thanks in advance.

  • In SSRS you would use the CDate() function to change from varchar() to datetime; but the issue is that you have non-date values (Amber) mixed into that column. Check your source data, see what that shows.

    HTH,

    Rob

  • for the Amber thing, just do a replace command to remove it before you format the date Replace("Amber", "")

    Marvin Dillard
    Senior Consultant
    Claraview Inc

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply