Access 2007-2019
Access 2000-2003
Access Seminars
TechHelp Support
Tips & Tricks
Access Forum
Course Index
Topic Glossary
Insider Circle
 
Home   News   Tips   Glossary   Templates   Forums   Help   Logon   Order   Contact Us  
 
Glossary

New Entries Added Almost Daily!
Click here to get on our Mailing List

   

   Access    Excel    Word    Windows    HTML

 
MS Access

Format

How to Format a value.

The Format functions comes in handy when you wish to display information in a different way to which it is stored, for instance you have a DateTime Field and you only wish to show a portion of it. It is best to store this in your Table as the full DateTime but then display it in a Query/Form or Report in a different manor.

The Format function returns returns a Variant (String) containing an expression formatted according to instructions contained in a format expression.

=Format(expression [, format] [, firstdayofweek] [, firstweekofyear])

expression the value to format.
format the type of formatting you wish to expression to return.
firstdayofweek a constant specifying the first day of the week.
firstweekofyear a constant specifying the first week of the week.


  • Dates
  • Numbers and Currency
  • Text and Memos
  • Yes/No

Dates

FirstDayOfWeek
ConstantValueDescription
vbUseSystem0First day of week specified in system settings (default)
vbSunday1Sunday
vbMonday2Monday (complies with ISO standard 8601, section 3.17)
vbTuesday3Tuesday
vbWednesday4Wednesday
vbThursday5Thursday
vbFriday6Friday
vbSaturday7Saturday

FirstWeekOfYear
ConstantValueDescription
vbUseSystem0Use System Settings
vbFirstJan11Start with week in which January 1 occurs (default)
vbFirstFourDays2Start with the first week that has at least four days in the new year
vbFirstFullWeek3Start with first full week of the year

Symbol
SymbolDescriptionRange
: (colon)Time separator. Separators are set in the regional settings of Windows.
/Date separator.
cSame as the General Date predefined format.
dDay of the month in one or two numeric digits, as needed.(1 to 31)
ddDay of the month in two numeric digits.(01 to 31)
dddFirst three letters of the weekday.(Sun to Sat)
ddddFull name of the weekday.(Sunday to Saturday)
dddddSame as the Short Date predefined format.
ddddddSame as the Long Date predefined format.
wDay of the week.(1 to 7)
wwWeek of the year.(1 to 53)
mMonth of the year in one or two numeric digits, as needed.(1 to 12)
mmMonth of the year in two numeric digits.(01 to 12)
mmmFirst three letters of the month.(Jan to Dec)
mmmmFull name of the month.(January to December)
qDate displayed as the quarter of the year.(1 to 4)
yNumber of the day of the year.(1 to 366)
yyLast two digits of the year.(01 to 99)
yyyyFull year.(0100 to 9999)
hHour in one or two digits, as needed.(0 to 23)
hhHour in two digits.(00 to 23)
nMinute in one or two digits, as needed.(0 to 59)
nnMinute in two digits.(00 to 59)
sSecond in one or two digits, as needed.(0 to 59)
ssSecond in two digits.(00 to 59)
tttttSame as the Long Time predefined format.
AM/PMTwelve-hour clock with the uppercase letters "AM" or "PM", as appropriate.
am/pmTwelve-hour clock with the lowercase letters "am" or "pm", as appropriate.
A/PTwelve-hour clock with the uppercase letter "A" or "P", as appropriate.
a/pTwelve-hour clock with the lowercase letter "a" or "p", as appropriate.
AMPMTwelve-hour clock with the appropriate morning/afternoon designator as defined in the regional settings of Windows.

Date
SettingDescription
General Date(Default) If the value is a date only, no time is displayed; if the value is a time only, no date is displayed. This setting is a combination of the Short Date and Long Time settings.
Examples: 4/3/93, 05:34:00 PM, and 4/3/93 05:34:00 PM.
Long DateSame as the Long Date setting in the regional settings of Windows.
Example: Saturday, April 3, 1993.
Medium DateExample: 3-Apr-93.
Short DateSame as the Short Date setting in the regional settings of Windows.
Example: 4/3/93.
WARNING The Short Date setting assumes that dates between 1/1/00 and 12/31/29 are twenty-first century dates (that is, the years are assumed to be 2000 to 2029). Dates between 1/1/30 and 12/31/99 are assumed to be twentieth century dates (that is, the years are assumed to be 1930 to 1999).
Long TimeSame as the setting on the Time tab in the regional settings of Windows.
Medium TimeExample: 5:34 PM.
Short TimeExample: 17:34.

Format the date to show the Week number:

VBA
	Format([Date], "ww")
	

Numbers and Currency

Number and Currency Formats
SettingDescription
General Number(Default) Display the number as entered.
CurrencyUse the thousand separator; follow the settings specified in the regional settings of Windows for negative amounts, decimal and currency symbols, and decimal places.
EuroUse the euro symbol (€), regardless of the currency symbol specified in the regional settings of Windows.
FixedDisplay at least one digit; follow the settings specified in the regional settings of Windows for negative amounts, decimal and currency symbols, and decimal places.
StandardUse the thousand separator; follow the settings specified in the regional settings of Windows for negative amounts, decimal symbols, and decimal places.
PercentMultiply the value by 100 and append a percent sign (%); follow the settings specified in the regional settings of Windows for negative amounts, decimal symbols, and decimal places.
ScientificUse standard scientific notation.

Sections
SectionDescription
FirstThe format for positive numbers.
SecondThe format for negative numbers.
ThirdThe format for zero values.
FourthThe format for Null values.

VBA
	$#,##0.00[Green]; ($#,##0.00)[Red]; "Zero";"Null"
	
Number and Currency Symbols
SymbolDescription
. (period)Decimal separator. Separators are set in the regional settings in Windows.
, (comma)Thousand separator.
0Digit placeholder. Display a digit or 0.
#Digit placeholder. Display a digit or nothing.
$Display the literal character "$".
%Percentage. The value is multiplied by 100 and a percent sign is appended
E- or e-Scientific notation with a minus sign (ā€“) next to negative exponents and nothing next to positive exponents. This symbol must be used with other symbols, as in 0.00Eā€“00 or 0.00E00.
E+ or e+Scientific notation with a minus sign (ā€“) next to negative exponents and a plus sign (+) next to positive exponents. This symbol must be used with other symbols, as in 0.00E+00.

Number and Currency Settings
SettingDataDisplay
General Number3456.789
-3456.789
$213.21
3456.789
-3456.789
$213.21
Currency3456.789
-3456.789
$3456.789
($-3456.789)
Fixed3456.789
-3456.789
3.56645
3456.789
-3456.789
3.57
Standard3456.7893,456.79
Percent3
300%
0.45
45%
Scientific3456.789
-3456.789
3.46E+03
-3.46E+03

Examples
SettingDescription
0;(0);;"Null"Display positive values normally; display negative values in parentheses; display the word "Null" if the value is Null.
+0.0;-0.0;0.0Display a plus (+) or minus (-) sign with positive or negative numbers; display 0.0 if the value is zero.

Text and Memos

Symbols
SymbolDescription
@Text character (either a character or a space) is required.
&Text character is not required.
<Force all characters to lowercase.
>Force all characters to uppercase.

Sections
SectionDescription
FirstFormat for fields with text.
SecondFormat for fields with zero-length strings and Null values.

Examples
SettingDataDisplay
@@@-@@-@@@@465043799465-04-3799
@@@@@@@@@465-04-3799
465043799
465-04-3799
465043799
>richard
RICHARD
Richard
RICHARD
RICHARD
RICHARD
<alex
ALEX
Alex
alex
alex
alex
@;"Unknown"Null value
Zero-length string
Any text
Unknown
Unknown
Same text as entered is displayed

Yes/No

Sections
SectionDescription
FirstThis section has no effect on the Yes/No data type. However, a semicolon (;) is required as a placeholder.
SecondThe text to display in place of Yes, True, or On values.
ThirdThe text to display in place of No, False, or Off values.

	; "Always"[Blue]; "Never"[Red]
	
Courses

Access 2013 Access Expert 27

Search

You can find more about this by searching the website.


Alex Hedley (Avatar) By: Alex Hedley


Click here to sign up for more FREE tips

 

You may want to read these articles from the 599CD News:

 

Learn
 
Accessindex
Excelindex
Wordindex
Windowsindex
PowerPointindex
Photoshopindex
Visual Basicindex
ASPindex
Seminars
More...
Customers
 
Account Login
Online Theater
Downloads
Lost Password
Free Upgrades
Insider Circle
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Articles
Search Our Site
Waiting List
Production Schedule
Collapse Menus
Help
 
Live Chat
Customer Support
WalkThru Tutorials
Troubleshooting
FAQs
TechHelp
Consulting Services
About Us
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Order
 
Video Tutorials
Handbooks
MYOLP Memberships
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Gift CDs
Contact
 
Live Chat
General Info
Support Policy
Contact Form
Email Us
Mailing Address
Phone Number
Fax Number
Course Survey
Facebook    Twitter

Google Plus    LinkedIn

Blog RSS Feed    YouTube Channel
Richard Rost Microsoft MVP