2015年12月29日 星期二

Formatting Numbers and Dates in RDLC Report

引用

Formatting Numbers and Dates in RDLC Report

You can specify a format for numeric and date values by updating the Format property of its text box with a formatting string. For example, you can set a text box for a numeric field to display the number as currency. Reporting Services uses Microsoft .NET Framework formatting strings or you can create a custom formatting string for the Format property.

NoteNote:
To apply formatting to a text box, the text box must contain an expression, for example, =Fields!LineTotal.Value or =1000. If the text box is not an expression, that is, if the text in the text box does not begin with the equal (=) sign, then the text is interpreted as a string and formatting does not apply.

Formatting Numbers

The following table lists common .NET Framework number formatting strings.
Format string
Name
C or cCurrency
D or dDecimal
E or eScientific
F or fFixed-point
G or gGeneral
N or nNumber
P or pPercentage
R or rRound-trip
X or xHexadecimal
You can modify many of the format strings to include a precision specifier that defines the number of digits to the right of the decimal point. For example, a formatting string of D0 formats the number so that it has no digits after the decimal point. You can also use custom formatting strings, for example, #,###.

Formatting Dates

The following table lists common .NET Framework date formatting strings.
Format string
Name
dShort date
DLong date
tShort time
TLong time
fFull date/time (short time)
FFull date/time (long time)
gGeneral date/time (short time)
GGeneral date/time (long time)
M or mMonth day
R or rRFC1123 pattern
Y or yYear month

You can also a use custom formatting strings; for example, dd/MM/yy. For more information about .NET Framework formatting strings, see Formatting Types.

Expression
Result
 =Globals!ExecutionTime
03-07-2012 17:16
 =Format(Globals!ExecutionTime,"dd MMMM yyyy")
07-Mar-12
 =Format(Globals!ExecutionTime,"dd/MM/yyyy")
13-03-2012
 =Format(Globals!ExecutionTime,"dd-MM-yyyy")
13-03-2012
 =Format(Globals!ExecutionTime,"MM-dd-yyyy")
03-13-2012
 =Format(Globals!ExecutionTime,"yyyy-MM-dd HH mm")
13-03-2012 19:11
 =Format(Globals!ExecutionTime,"yyyy-MM-dd HH mm tt")
2012-03-13 19:11 PM
 =Format(Globals!ExecutionTime,"yyyy-MM-dd hh mm tt")
13-03-2012 19:11
 =Format(Globals!ExecutionTime,"dddd, MMMM dd yyyy")
Tuesday, March 13 2012
 =Format(Globals!ExecutionTime,"ddd,MMM d yyyy")
Tue,Mar 13 2012
 =Format(Globals!ExecutionTime,"ddd, MMM d "'"yy")
Sun, Jan 8 '06
 =Format(Globals!ExecutionTime,"dddd, MMMM dd")
Sunday, January 08
 =Format(Globals!ExecutionTime,"M/yy")
01-Jun
 =Format(Globals!ExecutionTime,"d")
01-08-2006
 =Format(Globals!ExecutionTime,"D")
Sunday, January 08, 2006
 =Format(Globals!ExecutionTime,"f")
Sunday, January 08, 2006 11:53 PM
 =Format(Globals!ExecutionTime,"F")
Sunday, January 08, 2006 11:53:52 PM
 =Format(Globals!ExecutionTime,"g")
01-08-2006 23:53
 =Format(Globals!ExecutionTime,"G")
01-08-2006 23:53
 =Format(Globals!ExecutionTime,"m")
Jan-08
 =Format(Globals!ExecutionTime,"r")
Sun, 08 Jan 2006 23:53:52 GMT
 =Format(Globals!ExecutionTime,"s")
2006-01-08T23:53:52
 =Format(Globals!ExecutionTime,"t")
11:53 PM
 =Format(Globals!ExecutionTime,"T")
11:53:52 PM
 =Format(Globals!ExecutionTime,"u")
2006-01-08 23:53:52Z
 =Format(Globals!ExecutionTime,"U")
Monday, January 09, 2006 5:53:52 AM
 =Format(Globals!ExecutionTime,"y")
January, 2006

沒有留言:

張貼留言