DateAndTime.Weekday(DateTime, FirstDayOfWeek) 方法
文章推薦指數: 80 %
VB 複製. Dim oldDate As Date Dim oldWeekDay As Integer oldDate = #2/12/1969# oldWeekDay = Weekday(oldDate) ' oldWeekDay now contains 4 because thisDate ...
跳到主要內容
已不再支援此瀏覽器。
請升級至MicrosoftEdge,以利用最新功能、安全性更新和技術支援。
下載MicrosoftEdge
其他資訊
目錄
結束焦點模式
語言
儲存
編輯
共用
Twitter
LinkedIn
Facebook
電子郵件
WeChat
目錄
語言
DateAndTime.Weekday(DateTime,FirstDayOfWeek)方法
定義
命名空間:
Microsoft.VisualBasic
組件:Microsoft.VisualBasic.Core.dll
組件:
組件:Microsoft.VisualBasic.dll
本文內容
傳回整數值,其中包含表示星期幾的數字。
Returnsanintegervaluecontaininganumberrepresentingthedayoftheweek.
publicstaticintWeekday(DateTimeDateValue,Microsoft.VisualBasic.FirstDayOfWeekDayOfWeek=Microsoft.VisualBasic.FirstDayOfWeek.Sunday);
staticmemberWeekday:DateTime*Microsoft.VisualBasic.FirstDayOfWeek->int
PublicFunctionWeekday(DateValueAsDateTime,OptionalDayOfWeekAsFirstDayOfWeek=Microsoft.VisualBasic.FirstDayOfWeek.Sunday)AsInteger
參數
DateValue
DateTime
必要。
Required.您想用來判斷星期幾的Date值。
ADatevalueforwhichyouwanttodeterminethedayoftheweek.
DayOfWeek
FirstDayOfWeek
選擇性。
Optional.選自FirstDayOfWeek列舉類型的值,指定一週的第一天。
AvaluechosenfromtheFirstDayOfWeekenumerationthatspecifiesthefirstdayoftheweek.如果未指定,就會使用Sunday。
Ifnotspecified,Sundayisused.
傳回
Int32
整數值,其中包含表示星期幾的數字。
Anintegervaluecontaininganumberrepresentingthedayoftheweek.
例外狀況
ArgumentException
DayOfWeek小於0或大於7。
DayOfWeekislessthan0ormorethan7.
範例
下列範例會使用Weekday函數,從指定的日期取得一周中的某一天。
ThefollowingexampleusestheWeekdayfunctiontoobtainthedayoftheweekfromaspecifieddate.
DimoldDateAsDate
DimoldWeekDayAsInteger
oldDate=#2/12/1969#
oldWeekDay=Weekday(oldDate)
'oldWeekDaynowcontains4becausethisDaterepresentsaWednesday.
備註
函數所傳回的值Weekday會對應到列舉的值FirstDayOfWeek;也就是說,1表示星期日,而7表示星期六。
ThevaluereturnedbytheWeekdayfunctioncorrespondstothevaluesoftheFirstDayOfWeekenumeration;thatis,1indicatesSundayand7indicatesSaturday.
注意
Weekday使用CurrentCultureCultureInfo命名空間中類別之屬性的目前行事曆設定System.Globalization。
WeekdayusesthecurrentcalendarsettingfromtheCurrentCulturepropertyoftheCultureInfoclassintheSystem.Globalizationnamespace.預設CurrentCulture值取決於主控台設定。
ThedefaultCurrentCulturevaluesaredeterminedbyControlPanelsettings.
DayOfWeek引數可以是下列其中一項設定。
TheDayOfWeekargumentcanhaveoneofthefollowingsettings.
列舉值Enumerationvalue
值Value
描述Description
FirstDayOfWeek.System
00
在[系統設定]中指定的每週第一天Firstdayofweekspecifiedinsystemsettings
FirstDayOfWeek.Sunday
11
星期日(預設)Sunday(default)
FirstDayOfWeek.Monday
22
星期一(符合ISO標準8601,第3.17節)Monday(complieswithISOstandard8601,section3.17)
FirstDayOfWeek.Tuesday
33
TuesdayTuesday
FirstDayOfWeek.Wednesday
44
星期三Wednesday
FirstDayOfWeek.Thursday
55
ThursdayThursday
FirstDayOfWeek.Friday
66
星期五Friday
FirstDayOfWeek.Saturday
77
星期六Saturday
適用於
另請參閱
Day(DateTime)
Month(DateTime)
Now
WeekdayName(Int32,Boolean,FirstDayOfWeek)
Year(DateTime)
DatePart
DateTime
此頁面有所助益嗎?
請為您的體驗評分
Yes
No
還有其他意見反應嗎?
系統會將意見反應傳送給Microsoft:按下[提交]按鈕,您的意見反應將用來改善Microsoft產品和服務。
隱私權原則。
送出
謝謝。
本文內容
延伸文章資訊
- 1VBScript Weekday Function - W3Schools
The Weekday function returns a number between 1 and 7, that represents the day of the week. Synta...
- 2WeekDay Function - Visual Basic 6.0 (VB 6.0) - Chennaiiq
WeekDay Function - Visual Basic 6.0 (VB 6.0). Returns a Variant (Integer) containing a whole numb...
- 3VB.NET DateAndTime.Weekday方法代碼示例- 純淨天空
本文整理匯總了VB.NET中Microsoft.VisualBasic.DateAndTime.Weekday方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET DateAndTime....
- 4Weekday Function - VB .NET Language in a Nutshell [Book]
- 5MS Excel: How to use the WEEKDAY Function (WS, VBA)
As a VBA function, you can use this function in macro code that is entered through the Microsoft ...