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.
Note:
|
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 c | Currency |
D or d | Decimal |
E or e | Scientific |
F or f | Fixed-point |
G or g | General |
N or n | Number |
P or p | Percentage |
R or r | Round-trip |
X or x | Hexadecimal |
Formatting Dates
The following table lists common .NET Framework date formatting strings.
Format string
|
Name
|
d | Short date |
D | Long date |
t | Short time |
T | Long time |
f | Full date/time (short time) |
F | Full date/time (long time) |
g | General date/time (short time) |
G | General date/time (long time) |
M or m | Month day |
R or r | RFC1123 pattern |
Y or y | Year 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
|
沒有留言:
張貼留言