Saturday, May 7, 2011

Data Types more (number formats)

The following number conversions assume that the country in the Windows Control Panel is set to "English (United States)."

Format syntax
Result
Format(8315.4, "00000.00")
08315.40
Format(8315.4, "#####.##")
8315.4
Format(8315.4, "##,##0.00")
8,315.40
Format(315.4,"$##0.00")
$315.40

The symbol for the decimal separator is a period (.), and the symbol for the thousands separator is a comma (,). However, the separator character that is actually displayed depends on the country specified in the Windows Control Panel.

Printing Formatted Dates and Times

To print formatted dates and times, use the Format function with symbols representing date and time. These examples use the Now and Format functions to identify and format the current date and time. The following examples assume that the Regional Settings dialog box of the Windows Control Panel is set to "English(United States)".


Format syntax
Result
Format(Now, "m/d/yy")
1/27/93
Format(Now, "dddd, mmmm dd, yyyy")
Wednesday, January 27, 1993
Format(Now, "d-mmm")
27-Jan
Format(Now, "mmmm-yy")
January-93
Format(Now, "hh:mm AM/PM")
07:18 AM
Format(Now, "h:mm:ss a/p")
7:18:00 a
Format(Now, "d-mmmm h:mm")
3-January 7:18



.

No comments:

Post a Comment