none
format datetime based on parameter

    Question

  • I have a ssrs report that takes a paramter sample time 

    i want to change the format based on this parameter 

    parameter       format

    hour         (datetime)

    daily        (mm/dd/yy)

    monthly (year-month)

    i am trying to write expression for custom date but its not working.

    Friday, December 06, 2013 12:00 AM

Answers

  • Hi Santosh,


    If I understand correctly, you want to format a date field based on the values of a parameter. After testing the issue in my local environment, we can use the expression below to achieve your requirement (Supposing the parameter named ReportParameter1, the filed named COL1):

    =switch(Parameters!ReportParameter1.Value="hour",Fields!COL1.Value,Parameters!ReportParameter1.Value="daily",format(cdate(Fields!COL1.Value),"MM/dd/yy"),Parameters!ReportParameter1.Value="monthly",format(cdate(Fields!COL1.Value),"yyyy-MM"))

    If you have any other questions, please feel free to ask.

    Regards, 
    Katherine Xiong


    Katherine Xiong
    TechNet Community Support

    • Marked as answer by rama rose Thursday, December 12, 2013 12:41 AM
    Sunday, December 08, 2013 12:42 PM