日期:2009-12-18  浏览次数:21021 次

FormatDateTime 函数

返回表达式,此表达式已被格式化为日期或时间。

FormatDateTime(Date[, NamedFormat])

参数

参数

描述

date

Required. Any valid date expression (like Date() or Now())

必选项。要被格式化的日期表达式。(如Date()或Now())

format

Optional. A Format value that specifies the date/time format to use

可选项。指示所使用的日期/时间格式的数值

设置

NamedFormat 参数可以有以下值:

常数

描述

vbGeneralDate

0

Display a date in format mm/dd/yy. If the date parameter is Now(), it will also return the time, after the date

显示日期和/或时间。如果有日期部分,则将该部分显示为短日期格式。如果有时间部分,则将该部分显示为长时间格式。如果都存在,则显示所有部分。

vbLongDate

1

Display a date using the long date format: weekday, month day, year

使用计算机区域设置中指定的长日期格式显示日期

vbShortDate

2

Display a date using the short date format: like the default (mm/dd/yy)

使用计算机区域设置中指定的短日期格式显示日期。如默认的(月/日/年)

vbLongTime

3

Display a time using the time format: hh:mm:ss PM/AM

使用计算机区域设置中指定的时间格式显示时间

vbShor