名称 | 语法 | 功能 | 例句 |
CDate | CDate(date) | 返回date类型的表达式,date 参数是任意有效的日期或字符串表达式。 | MyDate = "October 19, 1962" MyShortDate = CDate(MyDate) |
Date | Date | 返回当前系统日期。不带() | MyDate = Date |
DateAdd | DateAdd(interval, number, date) | 返回已添加指定时间间隔的日期。 | 下例将95 年1 月31 日加上一 个月: NewDate = DateAdd("m", 1, "31-Jan-95") |
DateDiff | DateDiff(interval,date1, date2) | 返回两个日期之间的时间间隔。 | xx= DateDiff("d", Now, theDate) |
DatePart | DatePart(interval, date) | 返回给定日期的指定部分。参考interval参数的可选值。 | GetQuarter = DatePart("q", TheDate) |
DateSerial | DateSerial(year, month, day) | 对于指定的年、月、日,返回 Date 子类型的 Variant。 | MyDate2 = DateSerial(1990-10, 8-2, 1) |
DateValue | DateValue(date) | 返回 Date 子类型的变量。date 参数应是字符串。 | DateValue("September 11, 1963") |
Day | Day(date) | 返回1 到 31 之间的一个整数,代表某月中的一天。 | MyDay = Day("October 19, 1962") 'MyDay =19。 |
Hour | Hour(Time) | 返回0到23之间的一个整数,代表某小时数。Time参数是时间表达式。 | MyTime = Now MyHour = Hour(MyTime) |
IsDate | IsDate(expression) | 返回Boolean值指明某表达式是否可以转换为日期。expression 参数可以是任意可被识别为日期和时间的日期表达式或字符串表达式。 | MyDate = "October 19, 1962" YourDate = #10/19/62# NoDate = "Hello" MyCheck= IsDate(MyDate) 'True MyCheck= IsDate(YourDate)'True MyCheck= IsDate(NoDate) 'False |
Minute | Minute(Time) | 返回0到59之间的整数,代表分钟。 | MyVar = Minute(Now) '=41 |
Month | Month(date) | 返回 1到12 之间的一个整数,代表某月份数。 | MyVar=Minute("October 19, 1962") 'MyVar = 10 |
MonthName | MonthName(month) | 返回表明指定月份的字符串。month是数值 | thismanth = MonthName(10)' ’thismanth = "October" |
Now | Now | 返回系统的当前日期和时间值。 | Today = Now ' today = "02-07-04 11:41:14" |
Second | Second(Time) | 返回 0到 59之间的一个整数,代表某秒数。 | MySec = Second(Now) 'MySec =14 |
Time | Time | 返回当前的系统时间。
| MyTime = Time 'MyTime = "11:41:14" |
Timer | Timer | 返回午夜 12 时以后已经过去的秒数。 | |
TimeSerial | TimeSerial(h,m,s) | 返回含有指定时h、分m、秒s的时间。 | MyTime1 = TimeSerial(12-6,-15,0) ' 返回 "5:45:00 AM." |
TimeValue | TimeValue(time) | 返回包含时间的 Date子类型的变量。 time 参数通常是代表时间表达式。 | MyTime = TimeValue("4:35:17 PM") |
Weekday | Weekday(date) | 返回代表一星期中某天的整数0到6。 | MyDate = #October 19, 1962# MyWeekDay = Weekday(MyDate) |
WeekdayName | WeekdayName(weekday) | 返回指定某天是星期几的字符串。 | MyDate= WeekDayName(1)'Sunday |
Year | Year(date) | 返回一个代表某年的整数。 | MyYear = Year(now) '2002 |
FormatDateTime | FormatDateTime(Date[, NamedFormat]) | 返回表达式,此表达式已被格式化为日期或时间。NamedFormat=0,1,2,3,4 | GetCurrentDate = FormatDateTime(Date, 1) |