This is a migrated thread and some comments may be shown as answers.

Formating Date from parameter

8 Answers 2826 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 2
Joe asked on 02 Apr 2012, 06:12 PM
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?


8 Answers, 1 is accepted

Sort by
0
Engineering
Top achievements
Rank 1
answered on 03 Apr 2012, 12:05 AM
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.

0
Tam
Top achievements
Rank 1
answered on 16 Oct 2012, 09:05 AM

Hi, Stephen!

Thank you verry much! :)

0
Efren
Top achievements
Rank 1
answered on 07 Aug 2014, 03:27 AM
[quote]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.[/quote]

Thank you. This helped me format the Date Range in my report. 
0
Lukasz
Top achievements
Rank 1
answered on 25 Jun 2015, 11:26 AM

[quote]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.
[/quote]

 

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

 

0
Nasko
Telerik team
answered on 25 Jun 2015, 02:29 PM
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
0
Robert
Top achievements
Rank 1
answered on 28 Jun 2015, 09:01 PM

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

0
Vivekveer
Top achievements
Rank 1
answered on 28 Sep 2016, 10:39 AM

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

0
Punprom
Top achievements
Rank 2
answered on 09 Mar 2018, 04:08 PM

Hi Vivekveer,

Do you know how to format date but keeps Globalization in place. Set the format, when runs in US see US date format when runs in UK see UK date format etc. Thanks.

Tags
General Discussions
Asked by
Joe
Top achievements
Rank 2
Answers by
Engineering
Top achievements
Rank 1
Tam
Top achievements
Rank 1
Efren
Top achievements
Rank 1
Lukasz
Top achievements
Rank 1
Nasko
Telerik team
Robert
Top achievements
Rank 1
Vivekveer
Top achievements
Rank 1
Punprom
Top achievements
Rank 2
Share this question
or