WeekDay
Result = WeekDay ( Date )
返回
Date指定的日期是星期几。
返回一个0(星期日)到6(星期六)之间的整数,表示_Date_参数描述的是星期几。
关于一星期中各天描述的常数表,可以看
预定义常数。
Gambas 使用延伸到过去的公历, 因此,从1582年10月15日起,关于星期才是真正准确的。
详细情况请参阅
日期和日历 .
示例
Print Now; " -> "; WeekDay(Now)
If WeekDay("6/8/2008") = 0 Then
Print "It is a Sunday"
Else
Print "It is not a Sunday"
Endif
Dim DayNames As String[]
Dim D As Date
DayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
D = "6/8/2008"
Print "It was a "; DayNames[WeekDay(D)]; " on "; Format$(D, "d mmm,yyyy")
It was a Sunday on 8 Jun,2008
' This example gives the date for the next coming sunday
Dim D As Date
D = DateAdd(Now, gb.Day, 7 - WeekDay(Now))
Print "The next Sunday falls on "; Format$(D, "d mmm,yyyy")
The next Sunday falls on 10 Feb,2019
参见