日期:2009-06-19  浏览次数:21017 次

FormatDateTime Function<br>
Returns an expression formatted as a date or time. <br>

<br>
FormatDateTime(Date[, NamedFormat])<br>
<br>
Arguments<br>
Date<br>
<br>
Required. Date expression to be formatted.<br>
<br>
NamedFormat<br>
<br>
Optional. Numeric value that indicates the date/time format used. If omitted, vbGeneralDate is used.<br>
<br>
Settings<br>
The NamedFormat argument has the following settings:<br>
<br>
Constant Value Description <br>
vbGeneralDate 0 Display a date and/or time. If there is a date part, display it as a short date. If there is a time part, display it as a long time. If present, both parts are displayed.&nbsp;&nbsp;<br>
vbLongDate 1 Display a date using the long date format specified in your computer's regional settings. <br>
vbShortDate 2 Display a date using the short date format specified in your computer's regional settings. <br>
vbLongTime 3 Display a time using the time format specified in your computer's regional settings. <br>
vbShortTime 4 Display a time using the 24-hour format (hh:mm). <br>
<br>
<br>
Remarks<br>
The following example uses the FormatDateTime function to format the expression as a long date and assign it to MyDateTime: <br>
<br>
Function GetCurrentDate<br>
&nbsp;&nbsp;&nbsp;' FormatDateTime formats Date in long date. <br>
&nbsp;&nbsp;&nbsp;GetCurrentDate = FormatDateTime(Date, 1) <br>
End Function<br>
Requirements<br>
Version 2 <br>
<br>