Formating Date from parameter

8 posts, 0 answers
  1. Joe
    Joe avatar
    51 posts
    Member since:
    Oct 2008

    Posted 02 Apr 2012 Link to this post

    I have two date pickers on my report that set two parameters (@BeginDate and @EndDate). In the header of the report and have this textbox:

    Date of data: {Parameters.BeginDate.Value} to {Parameters.EndDate.Value}

    When the user selects both dates and generate the report, the textbox displays

    Date of data: 4/1/2012 12:00:00 AM to 4/2/2012 12:00:00 AM

    I do not want the timestamp showing up as the user is only selecting a date. I tried to apply formating to the textbox {0:d} but that didn't work.

    Any suggestions?


  2. Edwin
    Edwin avatar
    6 posts
    Member since:
    Oct 2011

    Posted 02 Apr 2012 Link to this post

    You might try something like:
     Parameters.BeginDate.Value.Date
    or alternatively Format("{0:MM/dd/yyyy}",Parameters.BeginDate.Value.Date), I believe  {0:d} gives you the day of the month.

  3. DevCraft banner
  4. Tam
    Tam avatar
    2 posts
    Member since:
    Sep 2012

    Posted 16 Oct 2012 Link to this post

    Hi, Stephen!

    Thank you verry much! :)

  5. Efren
    Efren avatar
    8 posts
    Member since:
    Jun 2014

    Posted 06 Aug 2014 Link to this post

    You might try something like:
     Parameters.BeginDate.Value.Date 
    or alternatively Format("{0:MM/dd/yyyy}",Parameters.BeginDate.Value.Date), I believe  {0:d} gives you the day of the month.


    Thank you. This helped me format the Date Range in my report. 
  6. Lukasz
    Lukasz avatar
    21 posts
    Member since:
    Aug 2014

    Posted 25 Jun 2015 in reply to Edwin Link to this post

    Edwin said:You might try something like:
    Parameters.BeginDate.Value.Date
    or alternatively Format("{0:MM/dd/yyyy}",Parameters.BeginDate.Value.Date), I believe  {0:d} gives you the day of the month.

     

    Hi,

    I am trying to test second solution in textbox like this:

    From {Format("{0}",Parameters.Od.Value.Date)} to {Parameters.Do.Value}

    But  when adding "{0}" to inside expression I got error:

    Telerik.Reporting.Processing.Expressions.EmbeddedExpressionsException: Error evaluating embedded expressions: Unexpected token inside an expression at index 46

    How can I escape {} when passing argument to Format()?

     

    Thanks,

    Łukasz

     

  7. Nasko
    Admin
    Nasko avatar
    909 posts

    Posted 25 Jun 2015 Link to this post

    Hello Lukasz,

    If used in a string literal, curly brackets - { } should be escaped with double brackets like this: {{ or }}. More information on the topic can be found in the Embedded Expressions help article.

    Regards,
    Nasko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  8. Robert
    Robert avatar
    1 posts
    Member since:
    Jun 2015

    Posted 28 Jun 2015 Link to this post

    Hi, I'm also having the same issue when formatting a DateTime parameter in a TextBox.

    Here's what I have:

     

    Estimates  -  from {Format("{0:dd/MM/yyyy}", Parameters.startDate.Value.Date)} to {Parameters.endDate.Value}

    and I get the following error:

    ReportNameTextBox.Value expression [Estimates - from {Format("{0:dd/MM/yyyy}", Parameters.startDate.Value.Date)} to {Parameters.endDate.Value}] is not valid: Error evaluating embedded expressions: Unexpected token inside an expression at index 29

  9. Vivekveer
    Vivekveer avatar
    4 posts
    Member since:
    Sep 2016

    Posted 28 Sep in reply to Robert Link to this post

    Hi Robert,

    Try {Format("{{0:dd/MM/yyyy}}", Parameters.startDate.Value.Date)} instead of {Format("{0:dd/MM/yyyy}", Parameters.startDate.Value.Date)}.

    Thanks

    Vivek

Back to Top
DevCraft banner