Returns a Variant (String) containing an expression formatted according to instructions contained in a format expression.
Syntax
Format(expression[, format[, firstdayofweek[, firstweekofyear]]])
The Format function syntax has these parts:
Part | Description |
---|---|
expression | Required. Any valid expression. |
format | Optional. A valid named or user-defined format expression. |
firstdayofweek | Optional. Specifies the first day of the week. |
firstweekofyear | Optional. Specifies the first week of the year. |
Settings
The firstdayofweek argument has these settings:
Value | Description |
---|---|
0 | Use NLS API setting. |
1 | Sunday (default) |
2 | Monday |
3 | Tuesday |
4 | Wednesday |
5 | Thursday |
6 | Friday |
7 | Saturday |
The firstweekofyear argument has these settings:
Value | Description |
---|---|
0 | Use NLS API setting. |
1 | Start with week in which January 1 occurs (default). |
2 | Start with the first week that has at least four days in the year. |
3 | Start with the first full week of the year. |
Remarks
To Format | Do This |
---|---|
Numbers | Use predefined named numeric formats or create user-defined numeric formats. |
Dates and times | Use predefined named date/time formats or create user-defined date/time formats. |
Date and time serial numbers | Use date and time formats or numeric formats. |
Strings | Create your own user-defined string formats. |
If you try to format a number without specifying format, Format provides functionality similar to the Str function, although it is internationally aware. However, positive numbers formatted as strings using Format don't include a leading space reserved for the sign of the value; those converted using Str retain the leading space.