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

Force two digit minute field in text box display?

2 Answers 107 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 24 Oct 2011, 05:01 PM
Greetings,
   I am trying to display two dates in a single text box, along with other text (e.g., Reporting from: 10/20/2011 11:00 AM to 10/20/2011 12:45 PM), based on fields returned from an SQL query. The date fields are returned as SQL DateTime types. When breaking down the DateTime field for minutes under 10 (using the sub options presented in the Fields display of Edit Expression), I am only getting one digit to display. Is there a way to force that to format to 2 digits, have the leading zero display? If I put just the datetime field in a text box then the Format {0:f} (or other choices) seems to work, but once it's a mixed hard-code text and field value the overall Formatting doesn't work, not recognizing the datetime part vs the rest of the text in the Edit Expression list. [The main purpose in breaking this all up is to avoid the Seconds being displayed.]

What's in my "Edit Expression" window is:
Reporting From: {Fields.StartDate.DayOfWeek} {Fields.StartDate.Month}/{Fields.StartDate.Day}/{Fields.StartDate.Year} {Fields.StartDate.Hour}:{Fields.StartDate.Minute} {Fields.StartDate.Kind} to ...

What I get is:
Reporting from: Thursday 10/11/2011 11:0 Unspecified to ...

Also, the Fields.StartDate.Kind comes back "Unspecified", is there a simple error I'm making there too? Was expecting AM or PM.

Regards
Dave Clements

2 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 27 Oct 2011, 02:23 PM
Hello David,

You are correct for complex expressions the TextBox.Format is ignored. However to format DateTime you can use directly ToString as shown in the following sample:

= Fields.StartDate.ToString("f")+" to "+ Fields.EndDate.ToString("f")

Best wishes,
Peter
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

0
David
Top achievements
Rank 1
answered on 27 Oct 2011, 02:37 PM
Excellent! Works just like we want it to. Many thanks.
Tags
General Discussions
Asked by
David
Top achievements
Rank 1
Answers by
Peter
Telerik team
David
Top achievements
Rank 1
Share this question
or