WEEKDAY
Returns a number representing the day of the week for a given date.
Sample usage
WEEKDAY(Date)
Syntax
The following syntax returns a number between 0 and 6, starting from Sunday, that represents the day of the week.
WEEKDAY( date_expression )
The following syntax returns a number that represents the day of the week from a compatibility mode Date value.
WEEKDAY( X [, format_string ])
Parameters
date_expression- a Date & Time field or expression.X- a field or expression that evaluates to Text, Number, or compatibility mode Date.format_string- format forX. Optional ifXis correctly configured as a semantic date field.
Input format for compatibility mode dates
Supported date functions accept the following input formats if X is a Text field or expression, or compatibility mode Date:
BASIC: %Y/%m/%d-%H:%M:%SDEFAULT_DASH: %Y-%m-%d [%H:%M:%S]DEFAULT_SLASH: %Y/%m/%d [%H:%M:%S]DEFAULT_DECIMAL: %Y%m%d [%H:%M:%S]RFC_1123: for example, Sat, 24 May 2008 20:09:47 GMTRFC_3339: for example, 2008-05-24T20:09:47ZDECIMAL_DATE: same asDEFAULT_DECIMAL
Any valid strptime format is accepted.
Supported time functions accept the following input format if X is a Number field or expression:
SECONDS: seconds since EpochMILLIS: milliseconds since EpochMICROS: microseconds since EpochNANOS: nanoseconds since EpochJULIAN_DATE: days since Epoch
Examples
| Example formula | Input | Output |
|---|---|---|
WEEKDAY(Date) |
Jan 1, 2019 | 2 |
WEEKDAY(Date as Text, 'BASIC') |
2019/01/01-09:40:45 | 2 |
WEEKDAY(Date as Number, 'SECONDS') |
1561784874 | 6 |
| |
1562004058620 | 1 |
Notes
This function works with both compatibility mode dates and upgraded Date and Date & Time data types.
The following table describes the possible output of this function:
| Number | Day |
|---|---|
| 0 | Sunday |
| 1 | Monday |
| 2 | Tuesday |
| 3 | Wednesday |
| 4 | Thursday |
| 5 | Friday |
| 6 | Saturday |