vbscript中的year,vb vbscript

http://www.itjxue.com  2023-01-20 07:24  来源:未知  点击次数: 

在ASP中,使用vbscript在网页中显示目前日期

%=year(date)"年"month(date)"月"day(date)"日"weekdayname(weekday(now)) %

vb中的year()函数怎么理解? 例如:year(1)的结果为什么是:1899

year()函数用于输出年份,正确用法:

Dim a As Date

a = "2011-2-10"

Print Year(a) '输出结果:2011

如果a没有赋值为一个确切日期,将会从1899-12-31开始计算:

Dim a As Date

a = 1

Print a '输出结果:1899-12-31

Print Year(a) '输出结果:1899

请描述VB中year,month,day,weekday函数的使用方法,并举例说明

Private Sub Command1_Click()

' Year (Date) ' 从日期中取年

' Month (Date) ' 从日期中取月

' Day (Date) ' 从日期中取日

' Weekday(Date, [FirstDayOfWeek As VbDayOfWeek = vbSunday]) ' 从日期中取星期' 默认值从星期日(vbSunday)开始' 举例如下:Dim myDate As String

myDate = Date ' 2010-4-12

Print Year(myDate) ' 2010

Print Month(myDate) ' 4

Print Day(myDate) ' 12

Print Weekday(Date) ' 2

Print Weekday(Date, vbMonday) ' 1

End Sub

(责任编辑:IT教学网)

更多