WeekDay

Result = WeekDay ( Date )

Compute the week day of a date.

  • Date is the date to process.

Returns an integer between 0 (Sunday) and 6 (Saturday) that represents the day of the week.

See Predefined Constants for a list of constants associated with week days.

Gambas uses the Gregorian calendar extended to the past. Consequently the week day is only really accurate since October 15th 1582.

See Dates and calendars for more details.

Examples

Print Now; " -> "; WeekDay(Now)
05/16/2002 22:31:30 -> 4

If WeekDay("6/8/2008") = 0 Then
  Print "It is a Sunday"
Else
  Print "It is not a Sunday"
Endif
It is a Sunday

Dim DayNames As String[]
Dim D As Date

DayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]

= "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
= 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

See also