I am trying to build a string of multiple fields with line breaks and a formatted date. However I cannot get the Format function to work. Here is what I have
{Fields.title}<br />Since<br />Format('{0:MMM yyyy}', {Fields.StartDate})
Trying to get output like
CEO
Since
March 2010
5 Answers, 1 is accepted
Function Format(format, value) formats the value using the specified format string (check here).
Detailed information about date and time format specifiers can be found in Standard Date and Time Format Strings and Custom Date and Time Format Strings MSDN articles.
The formatting of a date directly in the HtmlTextBox expression, could be done by using ToString("MMMM yyyy"). Basically the whole expression has to include the following in order to show the desired output:
{Fields.title}<br />Since<br />{Fields.StartDate.ToString(
"MMMM yyyy"
)}
Regards,
Silviya
Progress Telerik
As a follow up from my last answer, there is another approach that would evaluate the same date format by using Embedded Expressions:
{Fields.title}<br />Since<br />{Format(
'{{0:MMM yyyy}}'
, Fields.StartDate)}
Note that curly brackets are special symbols, and should be escaped with double brackets like this: {{ or }}.
On the other hand, if you have a new item only for the date field, it can be used with an expression. To specify that is an expression, the value should be a string starting with equal (=) sign like the following:
=Format(
'{0:MMM yyyy}'
, Fields.StartDate)
Regards,
Silviya
Progress Telerik
Silviya,
The examples you have provided are not working for me. I am attempting to output the short date string of a report parameter in the header of the report. I am using an HtmlTextBox
By default I can get the long date time to display by simply calling
Date: {Parameters
.Date
.Value
}
To achieve the short date time string I have tried
={
Format
(
'{{0:mm/dd/yyyy}}'
, Parameters
.Date
.Value
)}
Date: {
Format
(
'{0:d}'
, Parameters
.Date
.Value
)}
Date: {Parameters
.Date
.Value
.ToString
(
"mm/dd/yyyy"
)}
Date: {Parameters
.Date
.Value
.ToShortDate
()}
Basically attempting to display the users chose parameters in the Report Header, can you guide me to the right approach?
It seems that this might work (modified from answer found at: format datetime inside HTMLTextBox expression - remove seconds)
Date: {
Format
(
'{{0:M/dd/yyyy}}'
, Parameters
.Date
.Value
)}
I'm happy to hear that you've found a solution. Let us know if you need further help.
Best,
Silviya
Progress Telerik