WEEKDAY

The function WEEEKDAY takes a date or a DateTime and returns a number indicating what day of the week the given date falls on.

This function takes either a single DateTime or a single date as input. It then returns a number indicating what day of the week the given date falls on. Count starts with 1 and Monday (that is, 1 represents Monday, 2 represents Tuesday, 3 represents Wednesday, et cetera). 

Declaration

WEEKDAY(datetime) -> day
WEEKDAY(date) -> day

 

Parameters

datetime (type: DateTime)
Any DateTime.

date (type: date)
Any date.

Return Values

day (type: number)
A number (1-7) indicating what day of the week is described by the given date or DateTime.
Count starts with 1 and Monday (that is, 1 represents Monday, 2 represents Tuesday, 3 represents Wednesday, et cetera). 

Examples

Assume the first example has access to the following DateTime value:

example_date_and_time = {  
 "date": {  
  "day": 1,  
  "month": 4,  
  "year": 2021  
 },  
 "time": {  
  "hour": 16,  
  "minute": 14,  
  "second": 38,  
  "millisecond": 0  
 },  
 "timeZone": "UTC"  
}

The date described in example_date_and_time is April 1st, 2021. This falls on a Thursday, which WEEKDAY indexes as 4. Thus, in the following example, when example_date_and_time is given as input for WEEKDAY, it returns the number 4:

WEEKDAY(example_date_and_time) = 4

The above example demonstrates how the WEEKDAY function behaves when given a DateTime as input. In order to further establish how the WEEKDAY function behaves when given a date as input, assume the last example has access to the following date value:

example_date = {  
 "day": 1,  
 "month": 4,  
 "year": 2021  
}

Note that the date described in example_date is identical to the date described in example_date_and_time. This is still a Thursday, when example_date is given as input for WEEKDAY, it returns the number 4:

WEEKDAY(example_date) = 4