Date, Time, and Number Formatting
In This Topic
In Section Reports, you can set formatting strings for date, time, currency, and other numeric values using the OutputFormat property on the TextBox control. The OutputFormat dialog also allows you to select international currency values and select from various built-in string expressions. In addition to the built-in string expressions, you may use any .NET standard formatting strings. You can find information about these strings (Numerics and Date/Time formats) on MSDN.
Note: The ReportInfo control has many preformatted options in the FormatString property for RunDateTime and Page Numbers. For more information, see ReportInfo (Section report).
Caution:
- The format from the OutputFormat property is applied to the value set in the DataField property or the Value property. It is not applied when a string is set in the Text property.
- OutputFormat property settings are valid only for Double or DateTime type values. In case of a String or when no data type is set, the format is automatically applied to only those values that can be converted to Double or DateTime, otherwise no format is applied.
The OutputFormat property allows four sections delimited by a semicolon. Each section contains the format specifications for a different type of number:
- The first section provides the format for positive numbers.
- The second section provides the format for negative numbers.
- The third section provides the format for Zero values.
- The fourth section provides the format for Null or System.DBNull values.
For example: $#,#00.00; ($#,#00.00_); $0.00; #
Dates:
- dddd, MMMM d, yyyy = Saturday, December 25, 2012
- dd/MM/yyyy = 25/12/2012
- d or dd = day in number format
- ddd = day in short string format (for example, Sat for Saturday)
- dddd = day in string format (for example, Saturday)
- MM = month in number format
- MMM = month in short string format (for example, Dec for December)
- MMMM = month in string format (for example, December)
- y or yy = year in two digit format (for example, 12 for 2012)
- yyyy or yyyy = year in four digit format (for example, 2012)
Times:
- hh:mm tt = 09:00 AM
- HH:mm = 21:00 (twenty-four hour clock)
- HH = hours in 24 hour clock
- hh = hours in 12 hour clock
- mm = minutes
- ss = seconds
- tt = AM or PM
Currency and numbers:
- $0.00 = $6.25
- $#,#00.00 = $06.25
- 0 = digit or zero
- # = digit or nothing
- % = percent-multiplies the string expression by 100
Note: Underscore (_) keycode can be used in OutputFormat property to skip the width of the next character. This code is commonly used as _) to leave space for a closing parenthesis in a positive number format when the negative number format includes parentheses. This allows both positive and negative values to line up at the decimal point.