Article ID: 102045 - Last Review: August 16, 2005 - Revision: 2.1

DOC: FORMAT$ Dates mm/dd/yy Gives MM-DD-YY in VB for MS- DOS

This article was previously published under Q102045
Expand all | Collapse all

SUMMARY

The FORMAT$ function uses the date separator as defined by the current country setting in MS-DOS. In the USA, that means it uses the dash or hyphen character (-) when printing dates instead of the forward slash '/'.

MORE INFORMATION

When printing date information, the FORMAT$ function replaces the slash '/' with the current country setting for the date separator. In the USA, the default MS-DOS date separator is the dash (-). Here's an example:
   PRINT FORMAT$(NOW, "mm/dd/yy")     ' prints 06-23-93
				
You can force FORMAT$ to use the slash (/) by preceding it with a backslash (\). Here's an example:
   PRINT FORMAT$(NOW, "mm\/dd\/yy")   ' prints 06/23/93
				
The Visual Basic for MS-DOS Help file topic 'Sample Date and Time Formats' shows the following example, which is incorrect for the USA:
   FORMAT$ Expression   Display         ' Will Display
   ------------------   -------------   ' -------------
   m/d/yy               12/7/58         ' 12-7-58
   m/d/yy h:mm          12/7/58 20:50   ' 12-7-58 20:50
				
To display the expected date format, use the backslash (\) in conjunction with the forward slash (/). The backslash is an operator that displays the next character in a format string.

APPLIES TO
  • Microsoft Visual Basic for MS-DOS
  • Microsoft Visual Basic 2.0 Standard Edition
  • Microsoft Visual Basic 3.0 Professional Edition
  • Microsoft Visual Basic 2.0 Professional Edition
Keywords: 
kbdocfix KB102045
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
 

Article Translations