Public Function YearStart(WhichYear As Integer) As Date Dim WeekDay As Integer Dim NewYear As Date NewYear =DateSerial(WhichYear, 1, 1) WeekDay =(NewYear - 2) Mod 7 If WeekDay < 4 Then YearStart = NewYear - WeekDay Else YearStart = NewYear - WeekDay + 7 End If End Function ...
TimeSerial(hour, minute, second) - 返回一个 Variant (Date),包含具有具体时、分、秒的时间。 DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]]) - 返回 Variant (Long) 的值,表示两个指定日期间的时间间隔数目。 Second(time) - 返回一个 Variant (Integer),其值为 0 到 59 之...
'获取星期的显示Functiondisp(iAsInteger)SelectCaseiCase1disp="一"Case2disp="二"Case3disp="三"Case4disp="四"Case5disp="五"Case6disp="六"CaseElsedisp="日"EndSelectEnd Function'获取当月的天数FunctionGetDaysOfMonth(YearAsString,MonthAsString)AsIntegerDimDay1, Day2AsStringIfMonth="12"ThenGetDays...
The VBA WEEKDAY function is listed under the date category of VBA functions. When you use it in a VBA code,it returns the day number (ranging from 1 to 7)by using the number of the day from the supplied date. In simple words, it returns the number of days within the week. Syntax ...
(, 2)''农历月 ' IntToSimDay__$(, 3)''农历日 ' IntToSimDay__$(, 4)''24节气 ' 目前可使用至2010年 ' Function ChineCalender(iDate, Optional num As Integer = 0) ' num :0~8都可用,不输入num 预设值为0 ' 分别介绍0~8的用法 ' 假设A1:2002/12/22 ' ChineCalender(A1): 壬午年[...
First4Jan=Weekday(DateSerial(Yearf,1,4),2)OrdinalDate=Mid(Todayf,3,2)*7+Dayf-(First4Jan+3)For i=1To13If OrdinalDate-DayOfWeek(i)<=0Then monthf=i Dayf2=OrdinalDate-DayOfWeek(i-1)GoTo DateConstruction Else End If Next iDateConstruction:FinalDate=DateSerial(Yearf,monthf,Dayf2)MsgBox...
ActiveSheet.[B1].Value="星期"& disp(Weekday(DateStr, vbMonday))'设置单元格行列宽高自适应ActiveSheet.[A1].Columns.AutoFit ActiveSheet.[A1].Rows.AutoFit ActiveSheet.[B1].Columns.AutoFit ActiveSheet.[B1].Rows.AutoFitNextNextSheets(OriginSheet).DeleteOnErrorResumeNextApplication.DisplayAlerts=TrueEnd Su...
To determine the weekday of a date (from 1 to 7) or display it as a text format (Monday-Sunday, MON-SUN, M-S, etc.), there are several options available.To obtain the weekday number of a date (from 1 to 7), simply use the Weekday function:Sub example() dateTest = CDate("...
Weekday(date, [firstdayofweek]) 返回一个Variant (Integer),包含一个整数,代表某个日期是星期几 MsgBox的参数及用法 在消息框中显示信息,并等待用户单击按钮,可返回单击的按钮值(比如“确定”或者“取消”)。通常用作显示变量值的一种方式。 语法 MsgBox(Prompt[,Buttons][,Title][,Helpfile,Context]) ...
Weekday Function Named Arguments Yes Syntax Weekday(date, [ firstdayofweek]) date Use: Required Data Type: Variant Any valid date expression. firstdayofweek Use: Optional Data Type: Integer Constant value … - Selection from VB & VBA in a Nutshell: The