For dates that are stored in the date-time Type field of an Access database, the effect that is read directly from the database is shown with time, such as, 2009-06-13 18:00, what if just want to show the date?
Vbscrip has a function formatdatetime (). The description is as follows:
returns an expression that has been formatted as a date or time.
FormatDateTime (date[, NamedFormat])
parameter
Date
required option. The date expression to be formatted.
NamedFormat
can be selected. Indicates the value of the date/time format used, and if omitted, uses Vbgeneraldate.
Settings
The
NamedFormat parameter can have the following values:
constant |
value |
|
vbgeneraldate |
0 |
shows the date and/or time. If there is a date part, the section is displayed as a short date format. If there is a time section, the section is displayed in a long time format. If all exist, all parts are displayed. |
vblongdate |
1 |
|
vbshortdate |
2 |
|
Vblongtime |
3 |
Show time in the time format specified in the computer locale. |
vbShortTime |
4 |
use 24-hour format (hh:mm) Displays the time. |
Only the following code is available when you want to display the date: Strdate=formatdatetime (RS ("date"), 2). Because there is only one computer area in VBScript that is the United States, so there is only one short form of "YYYY-MM-DD".