Search code examples
reporting-servicesssrs-tablix

AM/PM showing as A3/P3 when trying to select substring of DateTime in SSRS?


I am trying to get just the AM/PM part from a DateTime column in SSRS. I have tried both =Right(Fields!Start_Time.Value,2) and =Format(Fields!Start_Time.Value,"tt") and both gives me A3s and P3s. I have also tried =IIF(DatePart("hour",Fields!Start_Time.Value) < 12, "AM", "PM") which just displayed the original DateTime, unformatted. What is causing this and how do I just get the AM/PM part?


Solution

  • Are you sure that your field is a DATE/TIME or does it just look like a Date/Time field?

    The only thing I can think of is that your field isn't actually a date/time type but just looks like one.

    Try using CDATE to convert the Start Time field to a Date/Time that can be Formatted.

    =Format(CDATE(Fields!Start_Time.Value),"tt")
    

    UPDATE: After reviewing your comments, I think you are putting the formula in the FORMAT property and not in the Expression. The way the question was written, I assumed you were populating the text box's Expression with the data formatted using the FORMAT function. If set the text box to the Start Time field and want to format using the FORMAT property, you would just put the in the FORMAT (tt) and not use the FORMAT function.

    enter image description here